Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import csv
- # Lectura de CSV:
- with open('datos.csv') as f:
- datos_csv = csv.reader(f)
- encabezado = next(datos_csv)
- print(encabezado)
- for registro in datos_csv:
- print(registro)
- # Escritura de CSV:
- encabezados = ['ID', 'Documento', 'Nombre', 'Ingreso', 'Telefono', 'Salario']
- filas = [('DEA4CB18-8100-8773-B718-186EB2946A8A', '1630060891599', 'Maxwell Coleman', 'March 16th, 2018', '1-439-528-9645', '$9,961'),
- ('10B867E0-D1FC-9861-56F0-33F8BA200D13', '1611082791499', 'Vladimir Long', 'September 5th, 2017', '1-308-724-5242', '$8,907'),
- ('92946EC2-3EA0-18BF-9841-F563E8157CE7', '1669092182599', 'Macon Estrada', 'August 13th, 2017', '1-312-687-9395', '$7,527')]
- with open('datos_2.csv', 'w') as f:
- datos_csv = csv.writer(f)
- datos_csv.writerow(encabezados)
- datos_csv.writerows(filas)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement