I have a csv file and I'm trying to read it via pandas command read_csv. However instead of reading 5 rows and 21 columns I get the following output:
There is a possible solution of manually changing the bad formatting of the file however, the real size is quite big(around 1GB) and it isnt possible to change it manually.
Consider below solution:
df = pd.read_csv("test.csv", sep="\"\,\"")
data = pd.concat([df.iloc[:,0].str.split(',', expand=True).rename(columns=dict(zip([0,1], df.columns[0].split(',')))), df.iloc[:,1:]], axis=1)
Would return a (5,21)
shape of data
.
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.