If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Unix Shell Scripts > parsing data from Flat file

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 08-21-06, 15:13
gauravjain21 gauravjain21 is offline
Registered User
 
Join Date: Mar 2005
Posts: 41
Question parsing data from Flat file

Hi all,

I've a flat file and has 10 lines or records that are not delimited by any space or delimiter. For each line, ie: SSN is position 10 to 19 and trailer death status is on line 10, position 20 to 21.

How do I view data in flat file where I specify a line number, from position and to position? Pls specify what function, command, syntax should I use, please provide an example.

Newbie
Reply With Quote
  #2 (permalink)  
Old 08-22-06, 02:25
pdreyer pdreyer is offline
Registered User
 
Join Date: May 2005
Location: South Africa
Posts: 1,268
You can use a while loop to loop tru the file
And use cut -c
see tread Shell script that parses a CSV file, builds sql insert calls, then executes them for example
Or to view e.g. line 3
sed -n '3p' flatfile | cut -c10-19,20-21
Reply With Quote
  #3 (permalink)  
Old 08-23-06, 18:28
gauravjain21 gauravjain21 is offline
Registered User
 
Join Date: Mar 2005
Posts: 41
Thanks a lot

It was really helpful as it will help me automate the flat file validation instead of the tedious manual validation using TextPad.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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
Trackbacks are On
Pingbacks are On
Refbacks are On