My csv file:
Mp4,Mp3,"1234554"
My code:
csv=csv=b''.join(csv).split(b'\n')
for index,row in enumerate(csv):
row=re.split(b''',(?=(?:[^'"]|'[^']*'|"[^"]*")*$)''',row)
for records in row:
print(records)
when it printing the records ,for the 3rd element it prints with ""i need to ignore this doubles quotes.
CodePudding user response:
I think this should do it:
records = records.replace("\"","")
Edit
Using pandas.read_csv
is better for working with csv files
import pandas as pd
csv = pd.read_csv('data.csv', delimiter=',', names=['x', 'y', 'z'])
# iterate over the dataframe
for index, row in csv.iterrows():
print(row['x'], row['y'], row['z'])
Assuming content of data.csv
looks like
Mp4,Mp3,"1234554"
The Output would look like this:
Mp4 Mp3 1234554
If your csv file includes column names e.g.
file_type1,file_type2,size
mp4,mp3,"1234554"
Just remove the names
parameter if you read in the csv file:
csv = pd.read_csv('data.csv', delimiter=',')
print(csv)
Then the Output would look like this:
file_type1 file_type2 size
0 mp4 mp3 1234554
Read more about pandas or pandas.read_csv
CodePudding user response:
You could easlily replace it with
print(records.replace('"',''))