dinsdag 10 juli 2018

pandas dataframe and CSV

Importeer CSV naar Dataframe

import pandas
factuurlines = pd.read_csv("df_debet_geschoond.csv",sep=";",engine='python' )

toelichting engine=python
“Error tokenising data. C error: EOF inside string starting at line”.

There was an erroneous character about 5000 lines into the CSV file that prevented the Pandas CSV parser from reading the entire file. Excel had no problems opening the file, and no amount of saving/re-saving/changing encodings was working. Manually removing the offending line worked, but ultimately, another character 6000 lines further into the file caused the same issue.

The solution was to use the parameter engine=’python’ in the read_csv function call. The Pandas CSV parser can use two different “engines” to parse CSV file – Python or C (default).



Exporteer Daframe naar CSV

 df_debet_geschoond.to_csv("df_debet_geschoond.csv", sep=";")

Geen opmerkingen:

Een reactie posten

Datums bepalen adhv begin en einddatum in Dataframe

Voorbeeld op losse velden  ####################################################################### # import necessary packages from datetime...