Skip to content

Instantly share code, notes, and snippets.

@thiagomarzagao
Created December 7, 2015 16:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thiagomarzagao/64c264f969112193d7fa to your computer and use it in GitHub Desktop.
Save thiagomarzagao/64c264f969112193d7fa to your computer and use it in GitHub Desktop.
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':
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