2

I have a data set in a CSV file where all of the data is encased within quotations ("). For example:

"10/10/2008,""15:48:09"",""760.40"","" -N-       NONE"""
"10/10/2008,""16:00:00"",""754.66"","" -N-       NONE"""
"10/10/2008,""16:15:00"",""761.83"","" -N-       NONE"""
"10/10/2008,""16:30:00"",""758.24"","" -N-       NONE"""

I have imported the csv file but the results still include quotations in the dataframe. For example:

0 "10/10/2008   "16:00:00""  "754.66""  " -N-   NONE""""

I need either a new method of importing this data from the CSV or a method for removing the extra quotation marks from the data.

This is how I imported the data:

NAME = pd.read_table('FileName.csv', sep=',"')

I have tried to delete the quotations using a number of ideas I found on this site, but I get errors that I cant decipher. FYI, I am VERY new to this, if you couldn't tell. Any assistance would be greatly appreciated.

4

2 回答 2

1

这是格式错误的 CSV,您必须在尝试使用它之前对其进行修复。首先,您需要删除前导和尾随双引号,然后将 2 x 双引号替换为单引号。

像这样...

10/10/2008,"15:48:09","760.40"," -N-       NONE"
10/10/2008,"16:00:00","754.66"," -N-       NONE"
10/10/2008,"16:15:00","761.83"," -N-       NONE"
10/10/2008,"16:30:00","758.24"," -N-       NONE"
于 2012-12-07T09:38:03.293 回答
0

您可以再次尝试删除引号。然后导入它使用 ',' 作为唯一的分隔符: NAME = pd.read_table('FileName.csv', sep=',')

于 2012-12-07T09:30:48.307 回答