Is there a size limit on csv writerow?

0

I'll create a CSC of 1,341 lines (with header). In Python 3 I used the csv commands, but the created file has 1,282 lines

Line data is extracted from 1,340 PDFs, metadata. I created a list and a print to check, it's extracting everything right.

The CSV code:

import csv

conjunto = open('emendas_autores.csv', mode='w', encoding='latin_1')

resultado = csv.DictWriter(conjunto, fieldnames=["Arquivo", "Autor", "Assunto", "Data_Criacao", "Data_Moficacao"])

resultado.writeheader()

def salva_csv():
    print("+")
    print (arquivo)
    print (author)
    print (subject)
    print (creation_date)
    print(mod_date)
    print("+")
    resultado.writerow({'Arquivo': arquivo,
                   'Autor': author, 
                   'Assunto': subject,
                   'Data_Criacao': creation_date,
                   'Data_Moficacao': mod_date})
    return

Then the iteration that extracts the data from the PDFs and calls the function salva_csv() and each file

Please, would anyone know what could be wrong to stop at 1,282 lines? Is there a size limit in csv writerow?

    
asked by anonymous 16.09.2017 / 17:00

1 answer

0

I do not know exactly how the csv library works, but you could also use the pandas library to read and save csvs (I do not know if it's best for you).

You could do

import pandas as pd

csv = pd.read_csv('emendas_autores.csv')

dados = {
    'autor': ['autor1', 'autor2', 'autor3'],
    'assunto': ['assunto1', 'assunto2', 'assunto3']
}

df = pd.DataFrame(dados)

df.to_csv('nome_meu_csv.csv', index=False)
    
18.09.2017 / 19:13