Ralph H. Stoos Jr. wrote:
: The part I can't seem to get going has to do with making
: variables out of the header row in the CSV file. The way it
: needs to work is that the first row may be of differing lengths
: (extra fields).
So, the first row defines the names of columns on each
subsequent row (or line) of the CSV file.
: I want to have the standalone PERL script to make the variables
: and then allow the user to sort the data based on the contents
: of the columns (i.e. pull out the records that match one or more
: criteria).
When you say "records" are you referring to columns or rows?
How are you defining the term "variables"?
If you mean you want a data structure which will hold selected
columns from a CSV file, then it's a fairly trivial exercise. Use
a hash to hold array references of column values (a HOA in perldsc
in the docs). Key the hash on the column names you have selected.
: The final product would allow me to select the file, specify
: some thing like the value of the "PPM" or "Grain" (and
: combinations thereof), and write the output to a new CSV file.
You can access the fields of each row by using Text::CSV_XS or
Text::CSV_PP. These modules will also allow you to write properly
formatted CSV files.
HTH,
Charles K. Clarkson
--
Mobile Homes Specialist
Free Market Advocate
Web Programmer
254 968-8328
Don't tread on my bandwidth. Trim your posts.
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>