I have a file of the format, with a leading space before each line:
"Western Overseas",
"Western Overseas",
"^",
"--",
"^",
"--",
"--",
null,
24995,
9977,
"CR",
"Western Refrigeration Private Limited",
"Western Refrigeration Private Limited",
"[ICRA]A",
"--",
"[ICRA]A1",
"--",
"Stable",
null,
14951,
2346,
"CR",
I would like to convert it to a CSV file with format:
"Western Overseas","Western Overseas","^","--","^","--","--",null,24995,9977,"CR"
"Western Refrigeration Private Limited","Western Refrigeration Private Limited","[ICRA]A","--","[ICRA]A1","--","Stable",null,14951,2346,"CR"
I'm trying to use tr
but am having trouble since it either prints all output to one line and seems to replace newlines with a double newline. Any help is appreciated.
foo,bar
is required for the output.xxd test.txt | head -n 12
.00000000: 2022 5765 7374 6572 6e20 4f76 6572 7365 "Western Overse 00000010: 6173 222c 0a20 2257 6573 7465 726e 204f as",. "Western O 00000020: 7665 7273 6561 7322 2c0a 2022 5e22 2c0a verseas",. "^",.
awk '$1=$1' RS=',\n\n' infile
if you don't mind last comma for last line.