Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
cria Y.pkl
import os
import pickle
import numpy as np
basepath = '/caminho/ate/CSVs/' # altere conforme necessario
flist = [fname for fname in os.listdir(basepath) if '.csv' in fname]
grupos = []
classes = []
counter = 0
for fname in flist:
fbuffer = open(basepath + fname, mode = 'rb')
for line in fbuffer:
idx1 = line.index(',')
classe = line[:idx1]
if classe[0] == '2':
counter += 1
for e in ['\xef', '\xbb', '\xbf']:
classe = classe.replace(e, '')
subline1 = line[idx1 + 1:]
idx2 = subline1.index(',')
grupo = subline1[:idx2]
print counter
classes = np.array(classes)
pickle.dump(classes, open('Y.pkl', 'wb'))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment