Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re^3: Extract column of excel

by hdb (Monsignor)
on Jun 04, 2013 at 11:48 UTC ( [id://1036952]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Extract column of excel
in thread Extract column of excel

Your code works fine! I have only added a chomp but that does not really make a difference...

#!/bin/perl -w use strict; #variables you can change to suit your needs my $column_separator = ","; my $column_number = "2"; $column_number--; my @lines=<DATA>; foreach my $line (@lines){ chomp($line); my @columns = split(/$column_separator/,"$line"); print $columns[$column_number],"\n"; } __DATA__ 1,2,3,4 A,B,C,D

Replies are listed 'Best First'.
Re^4: Extract column of excel
by MynameisAchint (Novice) on Jun 05, 2013 at 05:17 UTC
    Hey thank you for replying , now the problem I am having is that when code gets a blank cell it does not copy it to the array , it copies the next entry in column but I desire that even blank cells be copied as blank entry in array

      Good morning. If you do not post some sample data, it is difficult to provide meaningful suggestions. The description of your problem is inconsistent with the code you have posted.

      split does not skip any empty field, apart from trailing ones. And I cannot see any way that it would use the next entry in column, ie from the next line.

Log In?
Username:
Password:

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

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

    No recent polls found

    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.