1

I'm reading data from a CSV that has single quotes, but I don't want the quotes to be part of the internal data. I'm used to the tradition that quotes are optional, and can be used to handle commas within the string fields. So rather than changing the input file, how I can remove quotes using Pandas, rather than stripping them out in the code itself.

dfRules = pd.read_csv(filenameRules, quoting=csv.QUOTE_NONE, quotechar="'") print ("---- Data Head ---- ") print (dfRules.head()) 

DataFile

PAYEECONTAINS,CATEGORY 'SOUTHWEST AIRLINES','Travel' 'GODADDY','Internet Services' 'AIRBNB','Travel' 

Output:

---- Data Head ---- PAYEECONTAINS CATEGORY 0 'SOUTHWEST AIRLINES' 'Travel' 1 'GODADDY' 'Internet Services' 2 'AIRBNB' 'Travel' 

1 Answer 1

2

I think

dfRules = pd.read_csv(filenameRules, quoting=csv.QUOTE_MINIMAL, quotechar="'") 

may solve.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.