Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

awk, sed or perl ???????????

Status
Not open for further replies.

scooter6

IS-IT--Management
Jul 10, 2001
44
US
Greetings all....not sure how I want to do the following task, so I'd like some input:

I have a 'fixed length' data file that looks like this:

John Robert Doe 1234 Main St
Robert Smith 9876 Elm Ave
William C Tennant Jr 1111 Walnut Rd

The output I need is an ASCII comma-delimmited file like:

"John","Robert","Doe","1234 Main St"
"Robert",,"Smith","9876 Elm Ave"
"William","C","Tennant, Jr","1111 Walnut Rd"

NOTE: ALL of the first four (4) fields are 20 characters
long. IF the second field is blank (middle name/initial),then obviously the delimmited file needs to account for that with the 'extra comma' between fields 1&2
i.e. &quot;Robert&quot;,,&quot;Smith&quot; <--- no middle name/init

Also, IF field 4 contains any record, it is the &quot;Jr/Sr&quot; field, so I need it to 'append' to the third field (last name)

Any suggestions on what would be easiest? I have played a bit with each of them but can't seem to get it to work correctly for each instance and each record??

thanks for everyone/anyone's help :)


scooter6
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top