[ale] Converting CSV files to column based flat files with awk?

Jeff Lightner jlightner at water.com
Wed Mar 7 14:54:47 EST 2007


Only problem with that is the columns aren't.  I believe he's looking
for fixed column width's.

 

Ale is fun

Auug has alees

 

Both have the same amount of white space but aren't really "columns".

 

e.g.

 

Ale          is          fun

Auug       has        alees

 

Been a while since I needed to do that - I *think* I used to do it by
piping through "pr".

 

________________________________

From: ale-bounces at ale.org [mailto:ale-bounces at ale.org] On Behalf Of
To: ale at ale.org
Charles Shapiro
Sent: Wednesday, March 07, 2007 1:27 PM
To: Atlanta Linux Enthusiasts
Subject: Re: [ale] Converting CSV files to column based flat files with
awk?

 

Uh, if it was me I'd be lookin' at tr(1) or sed(1), rather than awk.

It really depends in part on whether you have commas which are escaped
in some way in your infile, e.g.

my,very,educated,mother\,and her boyfriend,just,sent,us,nine,pumpkins

If there ain't any commas like this in your infile, then 

tr ',' '\t' < infile > outfile will change the delimiters into tabs.

Otherwise, Things could get Interesting.


-- CHS



On 3/7/07, Ned Williams <nedj10 at gmail.com> wrote:

Greeting Ale members,

 

I need to convert the lines of a csv file into collumned output I think
this is a function of awk but I cannot seem to find the right
combitnation of FS and RS options to get it done. Any ideas would be
greatly appreciated 

 

thanks

Ned

 


_______________________________________________
Ale mailing list
Ale at ale.org
http://www.ale.org/mailman/listinfo/ale

 

-------------- next part --------------
An HTML attachment was scrubbed...




More information about the Ale mailing list