LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Awk and setting the FS (https://www.linuxquestions.org/questions/programming-9/awk-and-setting-the-fs-713974/)

randomfish 03-24-2009 01:06 AM

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!

ghostdog74 03-24-2009 01:16 AM

check this out

randomfish 03-24-2009 01:29 AM

I've tried that but with no luck unfortunately...

ghostdog74 03-24-2009 02:40 AM

you have not tried hard enough.


All times are GMT -5. The time now is 03:47 AM.