Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re^3: Parse .csv file from FTP using Perl

by muba (Priest)
on Jun 21, 2012 at 00:48 UTC ( [id://977523]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Parse .csv file from FTP using Perl
in thread Parse .csv file from FTP using Perl

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?

  • Comment on Re^3: Parse .csv file from FTP using Perl

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

    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?

      So the CSV file would look like this?

      a,b,c 1,2,3

      How does any of the fields in line 2 correspond to any of the fields in line 1? I'm afraid I don't follow :)

      Edit: Wait, I think I get it now. What you want is a way to tell Perl, "hey, listen. What is the number of the field in the first line that has the value 'c'? Got that? Okay, now give me the value of the field with that number in the second line." Is that what you mean? There are actually several approaches, and I'm coming up with something momentarily. Hold on.

      Edit-edit: Yes, got it now. Okay, gimme a couple minutes.

        What I want the code to be doing is: Return the value in Row 2 which is in the same column as "b" is in Row 1. This means that the code would have to locate where "b" is first I guess. I assume I need to use this operator ~= and some looping or have all the values in the first row stored in an array and the check each element maybe..? And when I find the location of b just return the value in the second row which is in the same column as b...again I assume some kind of loop maybe? Thank you again I really appreciate your help!

        Edit: Yes this is exactly what I want. Thank you very much for the help :) I owe you big time for all this help:)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://977523]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (5)
As of 2024-04-19 23:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found