I am looking for any known tools or scripts which can convert my bcp files to csv files.
Input bcp file format:
- Fields separated by 'XXXXXXX'
- Rows separated by 'YYYYYYY'
- Fields contains special characters like CRLF,CR,LF,", Tab, comma etc...
Output format I want:
- Standard csv format file with comma delimited
- Field values should contain original content including special characters (I mean no addition or deletion of special character(s), CR should also not be deleted)
- The file able to cut by column index/name to select interested columns.
For this I did the following:
Transformed the bcp file to csv with few sed commands, with this I can open the file in MS excel program with proper alignment, and I could see content was not altered (as expected).
sed -i 's/\"/\"\"/g' $inFile
sed -i 's/XXXXXXX/","/g' $inFile
sed -i 's/YYYYYYY/"\n"/g' $inFile
sed -i '1s/^/\"/' $inFile
sed -i '$s/\"//' $inFile
sed -i -e '${/^$/d}' $inFile
sed -i '1s/^/"Header","added","here"\n/' $inFile
Tried csvkit tool:
csvcut $infile
This tool is selecting the preferred columns but modifying the content like deleting the CR.
Any ideas in this kind conversion?