I've been trying for hours to do the following to a file that I'm converting from CSV to pipe delimited. After it's been converted I want to remove only the pipe between two pipes. I don't know if that is possible.
Example:
Original input
X, Y, This is a | test for me, or
X, Y, This is a|test for me,
Original output:
| X | Y | This is a | test for me| or
|X|Y|This is a|test for me|
Desired output:
| X | Y | This is a test for me|
I have tried but I just can't do it, can't find the regexpr or sed - regexp has always been hard for me.
I'm new to C, script. I handled the conversion and also if we get something like Street name, apt number, so we remove the comma between name and apt but keep the one after number which is the one to be converted to pipe.
I do a cat
with several sed
events to handle other things, do you think is best to do it there and will do it to the 1k plus rows I have? It used an awk for part of the script which I'm also not familiar.
Is my question the best solution or should I handle it before I even convert it to pipe? I think what the script does too is enclose in double quotes cases like "street name, apt #", so that way it can just remove the comma inside the quotes.
No luck with several tries and
cat <input> | sed 's/ | / /g' | tr , '|'
or:
cat <input> | sed 's/ | / /g;s/,/\|/g'
this is the script that does what i describe above for the commas i need to add the pipe handler when it comes as my example because otherwise it divides my string into two
Anyone want to help?