1

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.

5
  • 2
    Please provide sample data. And what have your tried? Commented Aug 4, 2013 at 15:32
  • And sample code please. Are you using the csv module ? Commented Aug 4, 2013 at 15:36
  • Does this answer help with the thousands separator? stackoverflow.com/questions/11763204/… Commented Aug 4, 2013 at 15:55
  • Also see this recent (open) github issue: github.com/pydata/pandas/issues/4322 Commented Aug 4, 2013 at 15:59
  • Have you tried adding thousands="." to the argument list? Commented Aug 4, 2013 at 16:19

1 Answer 1

2

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

df = pd.read_csv(fileName, index_col=[indexParam], 
                          skiprows = rowsToSkip,
                          decimal = ',', nrows = rowsToRead)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.