Skip to content

Instantly share code, notes, and snippets.

@urkh
Created Mar 19, 2015
Embed
What would you like to do?
utilidad para procesar archivos csv
import csv
import sys
# periodo, cedula, carrera(200), materia, seccion(U), nota(EQ)
materias = ['EF3106', 'EF3301', 'EF3305', 'EF2420', 'EF2413', 'EF2415', 'EF2414', 'EF2417', 'EF2419',
'EF2418', 'EF1426', 'EF2404', 'EF2411', 'EF2408', 'EF2416', 'EF3302', 'EF2410', 'EF2403', 'EF3312', 'EF1424']
f = open(sys.argv[1], 'rb')
print sys.argv[1]
print sys.argv[2]
try:
reader = csv.reader(f)
ofile = open('resultado_migrar.csv', "wb")
ofile.write("Periodo;Cedula;Carrera;Materia;Seccion;Nota\n")
rownum = 0
for row in reader:
if rownum == 0:
pass
else:
row_cedula = row[0].split(";")[0]
for x in range(0, 20):
ofile.write(sys.argv[2] + ";" + row_cedula + ";200;" + materias[x] + ";U;EQ\n")
rownum += 1
finally:
f.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment