joined:Jan 4, 2011
Hello, I was wondering if anyone could help me with something.
I am not a programmer yet I am able to modify scripts to a certain extent. I have a script to read an existing CSV file and output via an SSI call. What I would like to do is to be able to read the third entry from the 3rd column/2nd row, for example:
Bob;565 Apple Tree Lane;Vancouver;Canada
Fred;1234 Maple Road;Montreal;Canada
I would need to get/print the word "Montreal" (third entry from the second line, or any of my choice) from an existing CSV file and output using SSI, but not in a table, just as plain text with no carriage return, can you help?
Here is the CGI script (via SSI) I am presently using. It works, yet it is printing the third entry from both lines. I need to extract/print the 3rd entry from the 2nd line only:
(may need to be completely rewritten)
# <!--#exec cgi="my_ssi_file.cgi" -->
use CGI::Carp qw(fatalsToBrowser);
my $csvfile = "/home/public_html/cgi-bin/database/mycsvfile.csv";
print "Content-Type: text/html\n\n";
open (CSV, "< $csvfile");
my $cols = (split(/;/));
[edited by: phranque at 9:36 am (utc) on Jan 5, 2011]
[edit reason] disable graphic smile faces [/edit]