Read CSV worksheet data to generate custom files

0

Friends, I'm having trouble creating a Python code that reads information from a CSV and creates TXT files with custom names according to the content of the CSV (reads the cell item and generates the file esse_name.txt) Can someone give me a light in this doubt?

    
asked by anonymous 13.10.2017 / 03:03

1 answer

0

After much research I found out how to do it, below:

import csv
import os

with open('lista.csv') as listacsv:
    leitor = csv.DictReader(listacsv)
for row in leitor:
    a = row['nome']
    b = row['empresa']

os.mknod("{}_{}.txt".format(a,b))
    
13.10.2017 / 10:37