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 01-20-2005, 03:07 PM   #1
johniccp
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?


Hi,

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
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 22,965
Blog Entries: 11

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


Cheers,
Tink
 
  


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
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


All times are GMT -5. The time now is 10:10 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