Created
December 7, 2015 16:20
-
-
Save thiagomarzagao/64c264f969112193d7fa to your computer and use it in GitHub Desktop.
cria Y.pkl
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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': | |
continue | |
counter += 1 | |
for e in ['\xef', '\xbb', '\xbf']: | |
classe = classe.replace(e, '') | |
subline1 = line[idx1 + 1:] | |
idx2 = subline1.index(',') | |
grupo = subline1[:idx2] | |
grupos.append(grupo) | |
classes.append(classe) | |
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