0
I have a difficulty in delimiting the cells of the CSV file, when I send the command to save the edited file in CSV escritor.writerow([linhas])
the default delimiter is ,
, the more I need to change to ;
because when I open the file on Excel, it does not recognize the breaking of cells with ,
, Then it’s all in one column.
My code is like this:
import csv
coluna_Heading = 0
coluna_Number = 1
with open("testeIfHeading00.csv", "r") as arquivo_lido, open("saida.csv", "w", newline= "") as arquivo_criado:
#def o leitor CSV do arquivo
leitor = csv.reader(arquivo_lido, delimiter=';')
#def o escritor CSV do arquivo
escritor = csv.writer(arquivo_criado, delimiter=';')
#percorre as linhas do arquivo a ser lido
separatec = " "
for linhas in leitor:
if (len(linhas[coluna_Number]) == 1) or len(linhas[coluna_Number]) <= 2:
separatec = linhas[coluna_Heading]
linhas.append(separatec)
print(linhas)
escritor.writerow([linhas])
Missing a code snippet
– Sveen