Python: split files using mutliple split delimiters
- by donalmg
Hi,
I have multiple CSV files which I need to parse in a loop to gather information.
The problem is that while they are the same format, some are delimited by '\t' and others by ','.
After this, I want to remove the double-quote from around the string.
Can python split via multiple possible delimiters?
At the minute, I can split the line with one by using:
f = open(filename, "r")
fields = f.readlines()
for fs in fields:
sf = fs.split('\t')
tf = [fi.strip ('"') for fi in sf]
Any suggestions are welcome.