pandas read csv with extra commas in column

后端 未结 2 1503
执念已碎
执念已碎 2020-12-05 20:07

I\'m reading a basic csv file where the columns are separated by commas with these column names:

userid, username, body

However, the body column

2条回答
  •  忘掉有多难
    2020-12-05 20:29

    Add usecols and lineterminator to your read_csv() function, which, n is the len of your columns.

    In my case:

    n = 5 #define yours
    df = pd.read_csv(file,
                     usecols=range(n),
                     lineterminator='\n',
                     header=None)
    

提交回复
热议问题