Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

.csv file

Status
Not open for further replies.

jinkys

Programmer
Sep 11, 2003
67
GB
I have a .csv file in the following format

123,"abc",456,"def,ghi",789

Anyone know how I can change the delimeters in this from comma to pipe (|)? noting there is a comma within a text field.

 
A starting point:
sed 's/\([0-9"]\),\([0-9"]\)/\1|\2/g' /path/to/input.csv > output

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
or simply
Code:
sed 's/,/|/g' old.csv > new


``The wise man doesn't give the right answers,
he poses the right questions.''
TIMTOWTDI
 
thanks guys but I've decided to use the quotewords function in perl

 
perluserpengo, have you read the OP ?
noting there is a comma within a text field
 
Sorry dude i didn't see that. My appologies


``The wise man doesn't give the right answers,
he poses the right questions.''
TIMTOWTDI
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top