LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 03-24-2009, 01:06 AM   #1
randomfish
LQ Newbie
 
Registered: Mar 2009
Posts: 2

Rep: Reputation: 0
Question Awk and setting the FS


I'm writing an awk script to parse a .csv file. These files are unique in that any commas inside quotes must be left alone and the quotes everywhere else changed into pipes.

So far, I have tried setting the field separator to commas and using gsub to swap out quotes with pipes, but that doesn't produce the results I am looking for.

A good example of what I'm trying to do is:
Input:
First Last,"Las Vegas, NV",80

Output:
First Last|Las Vegas, NV|80


Any suggestions would be highly appreciated!
 
Old 03-24-2009, 01:16 AM   #2
ghostdog74
Senior Member
 
Registered: Aug 2006
Posts: 2,695
Blog Entries: 5

Rep: Reputation: 240Reputation: 240Reputation: 240
check this out
 
Old 03-24-2009, 01:29 AM   #3
randomfish
LQ Newbie
 
Registered: Mar 2009
Posts: 2

Original Poster
Rep: Reputation: 0
I've tried that but with no luck unfortunately...
 
Old 03-24-2009, 02:40 AM   #4
ghostdog74
Senior Member
 
Registered: Aug 2006
Posts: 2,695
Blog Entries: 5

Rep: Reputation: 240Reputation: 240Reputation: 240
you have not tried hard enough.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
awk question on handling *.CSV "text fields" in awk jschiwal Programming 8 05-27-2010 06:23 AM
awk , I need help for awk, just a display function mcandy General 1 12-15-2008 12:21 PM
using awk on a awk result jpgauvin Programming 1 12-15-2008 03:57 AM
shell command using awk fields inside awk one71 Programming 6 06-26-2008 04:11 PM
Some comments on awk and awk scripts makyo Programming 4 03-02-2008 05:39 PM


All times are GMT -5. The time now is 06:14 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration