Extracting specific variables from a fixed-width data file

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • lunabelle22a
    New Member
    • Jul 2008
    • 1

    Extracting specific variables from a fixed-width data file

    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!
  • numberwhun
    Recognized Expert Moderator Specialist
    • May 2007
    • 3467

    #2
    Can you provide a sample of the data and re-explain, using that sample, exactly what you are looking for?

    Regards,

    Jeff

    Comment

    • KevinADC
      Recognized Expert Specialist
      • Jan 2007
      • 4092

      #3
      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.

      Comment

      Working...