0

I am having massive issues reading an csv which I can provide upon request (since I don't know how to upload here). It has the dot . as thousands separator which makes issues as stated before. Additionally, I need to use skipfooter=1 since my file has one empty line at the end. This makes the decimal="," not to work, even if there is no dot present ...

My files look like this:

Commerzbank AG Fakt.3xLongZ.09(09/unl.)CBK(WKN: CZ24PE B<F6>rse: LT Commerzbank)

Datum;Zeit;Er<F6>ffnung;Hoch;Tief;Schluss;Volumen
02.08.2013;14:00;0,033;0,033;0,023;0,028;0,00
01.08.2013;14:00;0,023;0,029;0,022;0,028;0,00
14.03.2013;13:00;0,125;0,125;0,094;0,105;0,00
13.03.2013;13:00;0,165;0,165;0,105;0,125;0,00

Don't miss the double empty line at the end not shown here. This makes the use of skipfooter essential, otherwise the date is not recognized correctly. My best try is:

s = pd.read_csv('test.csv', decimal=',',sep=';',
                parse_dates={'Dates': [0, 1]},
                index_col=[0], skipfooter=1, skiprows=3)

This reads date correct, but all numbers are not recognized.

Regards.

filmor
  • 30,840
  • 6
  • 50
  • 48

1 Answers1

1

Use nrows instead of skipfooter. The decimal option works with it

df = pd.read_csv(fileName, index_col=[indexParam], 
                          skiprows = rowsToSkip,
                          decimal = ',', nrows = rowsToRead)
d4v30912
  • 11
  • 2