Need a script to convert comma delimited files to semi colon delimited

Hi All,

I need a unix script to convert .csv files to .skv files (changing a comma delimited file to a semi colon delimited file). I am a unix newbie and so don't know where to start. The script will be scheduled using cron and needs to convert each .csv file in a particular folder to a .skv equivalent and create a token in the folder to show completion as well as a log showing the number of files and records converted for auditing.

Sample data ... before conversion

27981,13,"0901"," ","B18975362",1,"C",17,"1"," "," "," "
24875,12,"0901"," ","B24578942",0,"F",17,"0"," "," "," "

Sample data ... after conversion

27981;13;0901;;B18975362;1;C;17;1;;;;^ 
24875;12;0901;;B24578942;0;F;17;0;;;;^

Please note that the number of columns in each file to be converted could be different, but that each .skv should have the same number of columns as the source .csv

example source & target folder: /test/conv

Any help would be most appreciated

try..

sed 's/,/;/g; s/\"//g; s/$/;^/' file

Hi Pamu,

Thanks for the suggestion ... as I mentioned I am a complete newbie and dont know how I would write the script at all. Please could you give me a more detailed example that I could test on my data?

Many thanks

You can do sth like below...

$ cat file
27981,13,"0901"," ","B18975362",1,"C",17,"1"," "," "," "
24875,12,"0901"," ","B24578942",0,"F",17,"0"," "," "," "

$ sed 's/,/;/g; s/\"//g; s/$/;^/' file > out_file

$ cat out_file
27981;13;0901; ;B18975362;1;C;17;1; ; ; ;^
24875;12;0901; ;B24578942;0;F;17;0; ; ; ;^

Hope this helps you

Regards,

pamu

awk 'NR%2{gsub(/,/,";")}1' RS=\" ORS= file