Remove ^L from csv not working...

hello...
i have a requirement to convert a xls file to csv in RHEL 6.5 and ftp it to a windows location.
i am using xls2csv utility to convert the file in linux.

Input xls file attached...

I have used below commands to convert the file to csv:

xls2csv -x test.xls -s cp1252 -d 8859-1 > test.csv

And,

xls2csv -c\, test.xls > test.csv

The issue i am facing is after conversion, an empty line is adding everytime and it contains only "^L"

"A","B","C","D"
"1","2","3","4"
"2","3","4","5"
"3","4","5","6"
"4","5","6","7"
^L

To remove this control-L i tried below sed command...the output looks fine.

sed 's/^L//g' test.csv

But when I am redirecting this output to another csv file for example test2.csv, ^L appears again.

Can anybody please help?

Thanks in advance...

That's the \f or form feed representation.
Try to remove it as:

sed -e 's/\x0C//g' test.csv > another.test.csv

After that use another.test.csv
If you want to delete "in place" RHEL6 uses gnu sed which allows you to do this:

sed -ie 's/\x0C//g' test.csv

Now is gone from test.csv and you can use it.

1 Like

Or use:

tr -d '\f' < file > newfile
1 Like

All the suggestion works.. Thanks you so much...