I have a CSV file that looks like this,
title 1 "x,y,z,w" "1,2,3,4" title 2 "a,s,d,f,g,h,j,k,l,z,x,c,v,b,n,m" "1,2,3,4,5,6,7,8,9,1,2,3,4,5,6,7" "1,2,3,4,5,6,7,8,9,1,2,3,4,5,6,7" "1,2,3,4,5,6,7,8,9,1,2,3,4,5,6,7" "1,2,3,4,5,6,7,8,9,1,2,3,4,5,6,7" "1,2,3,4,5,6,7,8,9,1,2,3,4,5,6,7" "1,2,3,4,5,6,7,8,9,1,2,3,4,5,6,7" "1,2,3,4,5,6,7,8,9,1,2,3,4,5,6,7" title 3 x,y,z,w 1,2,3,4 I am trying to read this CSV file which has a different column structure, which I was able to do that using skiprows, skipfooter, and quoting=csv.QUOTE_NONE. I am using quoting=csv.QUOTE_NONE to interpret the double-quotes (") row with different columns, not as a single string.
import csv import pandas as pd title_1 = 0 title_2 = 3 title_3 = 12 total = 14 title_1_df = pd.read_csv("test_csv.csv", engine='python', skiprows=title_1 + 1, skipfooter =(total - title_2) + 1, quoting=csv.QUOTE_NONE) title_2_df = pd.read_csv("test_csv.csv", engine='python', skiprows=title_2 + 1, skipfooter=(total - title_2) + 1, quoting=csv.QUOTE_NONE) title_3_df = pd.read_csv("test_csv.csv", engine='python', skiprows=title_3 + 1) I was able to read the CSV file, but the double quotes also came with it in DataFrame. Below is the output.
Is there a way to remove the double quotes while reading the CSV file? As you can see in the output of title_1_df and title_2_df double quotes are coming in the first and last column and I would like to the output as title_3_df.