Login or Sign up Help | Site Map
Connecting Tech Pros Worldwide

Extracting specific variables from a fixed-width data file

Question posted by: lunabelle22a (Newbie) on July 3rd, 2008 05:47 PM
Hi,

I have 125 unique variables and corresponding values in a data file with 6 fixed-width columns (columns alternate between "variables" and "values"). If I only need 6 of these variables and their values, which are scattered throughout the file, what are some suggestions to put into my script in order to extract them and them only? Is there a way to locate specific keys and ignore the others?

Thanks for your help!
Would you like to answer this question?
Sign up for a free account, or Login (if you're already a member).
numberwhun's Avatar
numberwhun
Forum Leader
1,846 Posts
July 3rd, 2008
05:55 PM
#2

Re: Extracting specific variables from a fixed-width data file
Can you provide a sample of the data and re-explain, using that sample, exactly what you are looking for?

Regards,

Jeff

Reply
KevinADC's Avatar
KevinADC
Expert
3,048 Posts
July 3rd, 2008
09:57 PM
#3

Re: Extracting specific variables from a fixed-width data file
Quote:
Originally Posted by lunabelle22a
Hi,

I have 125 unique variables and corresponding values in a data file with 6 fixed-width columns (columns alternate between "variables" and "values"). If I only need 6 of these variables and their values, which are scattered throughout the file, what are some suggestions to put into my script in order to extract them and them only? Is there a way to locate specific keys and ignore the others?

Thanks for your help!


for fixed-width records unpack is the most efficient function. You can also use substr. You can look both of those perl functions up online or in your local perl documentation.

Reply
Reply
Not the answer you were looking for? Post your question . . .
182,538 Experts ready to help you find a solution.
Sign up for a free account, or Login (if you're already a member).

Top Perl Forum Contributors