Posteado por: 1000tonlab | marzo 2, 2012
CSV to JSON with Python
1: import csv
2 : import json
3 : f = open(‘/tmp/archivo.txt’,'r’)
4 : reader = csv.DictReader(f,fieldnames=(‘campo1′,’campo2′,’campo3),delimiter=’;')
5: lineas = [l for l in reader]
6: salida = json.dumps(lineas)
7: open(‘/tmp/archivo.json’,'w’).write(salida)
Me gusta:
Me gusta Cargando...