Apuntes_Python/01_curso/Modulo_2/2-2f_leer_escribir_CSV.py

22 lines
629 B
Python
Raw Normal View History

2022-12-24 22:41:20 -03:00
import csv
"""
Leer CSV - csv.reader(archivo.csv)
"""
with open('ejm.csv', 'r') as csv_arch:
reader = csv.reader(csv_arch)
for row in reader:
#print('\t'.ljust(2).join(row))
print('{0:8}\t{1:8}\t{2:8}\t{3:8}'.format(*row))
#print('{0:8}\t{1:8}\t{2:8}\t{3:8}'.format(row[0], row[1], row[2], row[3]
#print('\n', help(row)) # las filas son listas
"""
Escribir CSV - csv.writer(arch.csv).writerow(['elementos','a','escribir'])
"""
with open('ejm.csv', 'a') as csv_arch:
writer = csv.writer(csv_arch)
writer.writerow(['Elvira', 'Zápáté', '34467845', 'lervielpare@zumail.zen'])