Auto correct a csv file using UNIX shell script.

Hi All,

There are list of 4-5 .csv files which has 12 columns.In some cases one of the record is split into 2 records. What needs to be done is this split record has to be auto corrected and placed in the csv file.

Eg:

Let us consider sample.csv file and in normal conditions the file would like below.

a,b,c,d,g,h,i,j,k,l,m,n
a,b,c,d,g,h,i,j,k,l,m,n
a,b,c,d,g,h,i,j,k,l,m,n
a,b,c,d,g,h,i,j,k,l,m,n

In some cases the sample.csv file would look like

a,b,c,d,g,h,i,j,k,l,m,n
a,b,c,d,g,h,
i,j,k,l,m,n
a,b,c,d,g,h,i,j,k,l,m,n
a,b,c,d,g,h,i,j,k,l,m,n

a,b,c,d,g,h,i,j,k,l,m,n
a,b,c,d,g,h
,i,j,k,l,m,n
a,b,c,d,g,h,i,j,k,l,m,n
a,b,c,d,g,h,i,j,k,l,m,n

If you see the line 2,3 the record is broken. It should be a single record.

How to identify the broken records?
How can we correct the file to look like the normal sample.csv file written earlier?

Thanks,
Karthik

Hello, and welcome to The Forums!

Please note that this sub-forum is for contacting forum staff.

Please post your question in the relevant technical sub-forum. Please also use code tags: here's a link to a thread with a video explaining how to do that: Using Code Tags.

Thank you!