I've come to this, so far:
Input:
fieldname1@data1
fieldname2@data2
fieldname3@data3
fieldname4@data4
fieldname1@data1
fieldname2@data2
fieldname3@data3
fieldname4@data4
fieldname1@data1
fieldname3@data3
fieldname4@data4
Output:
fieldname1,fieldname2,fieldname3,fieldname4
data1,data2,data3,data4
data1,data2,data3,data4
data1,,data3,data4
And after adding a few commas in the field3 data:
fieldname1,fieldname2,fieldname3,fieldname4
data1,data2,"data,,3",data4
data1,data2,"data,3",data4
data1,,"data,,,3",data4
Missing columndata sample:
fieldname1@data1
fieldname2@data2
fieldname4@data4
fieldname1@data1
fieldname3@data3
fieldname4@data4
fieldname1@data1
fieldname3@data3
With this output: (attention: columns are in the order found in the input!)
fieldname1,fieldname2,fieldname4,fieldname3
data1,data2,data4,
data1,,data4,data3
data1,,,data3