Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid

Re: Parse .csv file from FTP using Perl

by muba (Priest)
on Jun 21, 2012 at 00:27 UTC ( #977515=note: print w/replies, xml ) Need Help??

in reply to Parse .csv file from FTP using Perl

You're starting off great. I see you use strict;. Might I suggest that you use warnings; as well? And I see you've discovered how to work with modules, so you're on a good track here.

As for reading the CSV file, how about Text::CSV? There is a nice section about database programming in our tutorials library, you might want to have a look at that.

Good luck! Should you run into further problems, don't hesitate to ask.

Replies are listed 'Best First'.
Re^2: Parse .csv file from FTP using Perl
by Sherlock Perl (Novice) on Jun 21, 2012 at 00:39 UTC

    Thank you for the quick reply. Could you please direct me to some place where I can read how to parse the csv. The idea is that the file I am reaching to has 2 rows and I want to find the value in the 2nd row that corresponds to a specific value (assume "xyz") in the first row? How exactly should I go about doing this and storing the value from the 2nd row? Thank you in advance!

      Text::CSV will help you do that. I would hack together a little something for you, but uhm, you also need to know which field (or column, or whatever the CSV terminology for that is) the value appears in, am I right? Otherwise you're just saying something like, "search me a thing that is similar to the thing that grows on the tree!" Yeah, okay, but what sort of thing on what tree? Are we talking branches here? Apples? Pears? Leafs?

        Yes I perfectly understand your logic. I have two rows in the .csv file and lets say the .csv looks like this: A1 = a B1 = b C1 = c .... etc etc A2 = 1 B2 = 2 C2 = 3 .... etc etc. So I want to find the value in Row 2 (A2, B2, C2,...) that corresponds to lets say value "c" in Row1. It is basically like HLOOKUP function in excel. I am not sure if I am clear enough in explaining what I want to do?

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://977515]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (4)
As of 2018-05-25 21:15 GMT
Find Nodes?
    Voting Booth?