Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
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.


  Search this Thread
Old 01-20-2005, 03:07 PM   #1
LQ Newbie
Registered: Nov 2003
Location: Broome County, NY
Distribution: SUSE 10 SP 2
Posts: 20

Rep: Reputation: 0
gawk, comma delim to fixed length?


Is there a way to program gawk such that a 60 field comma delimited file is converted to a fixed length file? I'd like to set the length of each field.

I tried first editing the file using vi, and changing all commas to tabs, but the variety of data within fields resulted in a "abnormal" (not normalized) file.

If gawk is the wrong utility for the job, I'd like to know that too.

Thank you.
Old 01-20-2005, 04:21 PM   #2
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
gawk should do just fine ... you can parse the fields by
setting the FS appropriately and then output using printf
with padding .... voila.



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
separating a comma delimited line mrobertson Programming 7 07-27-2005 01:56 PM
problems reading in fixed-length record file naijaguy Programming 1 08-24-2004 02:34 PM
csv to fixed-length file roballen Programming 0 03-11-2004 03:12 AM
Comma key doesn't work mengkai Linux - Laptop and Netbook 1 03-05-2004 11:42 PM
comma delimited file cdragon Programming 5 06-21-2002 07:55 PM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 02:28 PM.

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