I have a kind of CSV file where the input for one logical line may be split over multiple physical lines.
Data example:
":T1","A1","B1","C1"
":T2","A2","B2","C2",
"D2","E2"
":T3","A3","B3","C3",
"D3"
":T4","A4"
This is four logical lines, with the continuation denoted by the trailing comma on the end of lines which split.
I tried to use the csv module in python:
import csv
with open('2.dat','r') as csvfile:
datreader = csv.reader(csvfile, delimiter=',' , quotechar='"')
for row in datreader:
print (', '.join(row))
print ("*******************************")
Which gives:
:T1, A1, B1, C1
*******************************
:T2, A2, B2, C2,
*******************************
D2, E2
*******************************
:T3, A3, B3, C3,
*******************************
D3
*******************************
:T4, A4
*******************************
What I'd like:
:T1, A1, B1, C1
*******************************
:T2, A2, B2, C2, D2, E2
*******************************
:T3, A3, B3, C3, D3
*******************************
:T4, A4
*******************************
I'm unsure of the best way to use csv module to parse this data correctly. Input data set could be millions of rows.
:T<number>