Hi,
I have a file with the following format -
Name,Age,"City, Country",Profession
Mitch,27,"Melbourne,Australia",Student
John,31,"Boston,USA",Chef
I want to make tis a tab separated file, but while ignoring the commas contained within the quotes with the output file looking like -
Name Age "City,Country" Profession
Mitch 27 "Melbourne,Australia" Student
John 31 "Boston,USA", Chef
Since I could not get a solution, I converted my file to tab delimited and then tried to revert it using sed with sed 's/"*'\t'*"/"*,*"/g'
in order to identify the quotes that contained any text followed by tab, then text again ending with quotes, and replace the tab with a comma, but what this gives me is
Mitch 27 "*,*"Melbourne Australia"*,*" Student
Thanks in advance.
is this an xy problem?
Hi,
Thanks for your response, but I feel my question was not clear enough.
When the raw file (.csv) is used, I want to replace all commas (except for the ones in quotes) by tab. In the last part, I mentioned that I converted the csv file entirely to a tab-delimited file, and then tried to convert "Melbourne Australia" to "Melbourne,Australia" which is not working.
Please post exact input and expected output.
Hi,
The input file has over 700 lines, so I am just putting up the header followed by 2 lines -
The expected output is -