Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options

Re: indefinite number of columns

by marto (Bishop)
on Jul 15, 2013 at 13:35 UTC ( #1044377=note: print w/replies, xml ) Need Help??

in reply to indefinite number of columns

Why not just parse each workbook of the spreadsheet using Spreadsheet::ParseExcel? The first example shows how to do this. Modifying this example to work on a per column basis (rather than by row) would be trivial.

Update: My mistake, you're working with a csv file.


1,2 ,3 1,2, 3 1,2,43 1 12,1 apple, 1, 3 orange 7,onion, 8, 9

Sample code using Text::CSV:

#!/usr/bin/perl use strict; use warnings; use Text::CSV; use Data::Dumper; my $csv = Text::CSV->new({ sep_char => ',' }); my $file = "book.csv"; open(my $csvdata, '<', $file) or die "Could not open '$file' $!\n"; while (my $line = <$csvdata>) { chomp $line; if ($csv->parse($line)) { my @fields = $csv->fields(); print Dumper \@fields; } }

What exactly are you trying to achieve?

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1044377]
[Corion]: A good morning to you too, Discipulus!
[Discipulus]: ah! buran stroke again?
[choroba]: Not sure what meteorological event it's been, but it's -6 now and lots of snow around.

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (3)
As of 2018-03-19 08:06 GMT
Find Nodes?
    Voting Booth?
    When I think of a mole I think of:

    Results (236 votes). Check out past polls.