Search code examples
pythonpandascsvexport-to-csv

How to read a CSV file in Pandas with quote characters?


I have a csv file dataset that looks like this:

dataset header

Date,"TTF_1M_15m","Own Trades (Sell)","Own Trades (Buy)"
2022-01-03 09:00:00,"68.54485294117647","",""
2022-01-03 09:15:00,"66.46498579545455","",""
2022-01-03 09:30:00,"69.53991935483872","",""
.......

I'm having trouble reading this into pandas due to the quotations.

So far I've been trying to use this line of code but I am just getting error messages:

data = pd.read_csv("APE_Data_Export_15min_2022.csv", sep=',', engine='python')

I would like the first line to indicate the 3 columns: TTF_1M_15m, Own Trades (Sell), Own Trades (Buy) with corresponding data underneath.

Would appreciate any help, thanks!


Solution

  • You can try using,

    df = pd.read_csv('APE_Data_Export_15min_2022.csv', sep=',', engine='python').replace('"','', regex=True)
    

    Output: enter image description here

    OUTPUT with actual data: enter image description here