简体   繁体   中英

Python: Reading CSV in results in ValueError: arrays must all be same length

I am trying to create a dataframe of the following very simple.csv

Content, Art, Version, Number, Question, Date, Performance, N1, Pall, Nall
somecontent, someart, 1.10.117, 081 01 04 02 01, 64936, 19.05.2018, 0.682427191039005, 8, 0.294000000, 29

As you can see, the different columns match (10 columns with 10 matching values in the row).

I have this csv saved as "bla.csv" (yeah someone is at a creative high) and do the following:

df=pd.read_csv('bla.csv')

This results in

ValueError: arrays must all be same length

Why?

When I try to replicate your problem it works perfectly fine at my computer. It could be that the separator gives an error. You can specify the separator by df=pd.read_csv('bla.csv', sep=',') . Depending on the way the csv-file is generated it could for example also be a semicolon.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM