Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: Help with converting Python script to Perl for CSV sort

by hippo (Bishop)
on Jan 31, 2017 at 14:36 UTC ( [id://1180689]=note: print w/replies, xml ) Need Help??


in reply to Help with converting Python script to Perl for CSV sort

It looks from the content of your post that you mean CSV rather than CVS. With that in mind you should definitely consider one of the CSV-based modules such as Text::CSV_XS rather than rolling your own.

I am not understanding the sort in the “foreach” loop… is this regex ?

No, this is sort. Perl has extensive, searchable, online documentation. Have a read of the linked page and see if that makes it all clear. Also perhaps the FAQ: How do I sort an array by (anything)?.

  • Comment on Re: Help with converting Python script to Perl for CSV sort

Replies are listed 'Best First'.
Re^2: Help with converting Python script to Perl for CSV sort
by jasonwolf (Sexton) on Jan 31, 2017 at 14:41 UTC
    Thank you for pointing out my mistype in CSV. I have started reading about the Text::CSV
      Python sucks
      use strict; use warnings; use Data::Dumper; use Spreadsheet::Read; use Text::CSV; my $book = ReadData("test.csv"); my @rows = sort { $a->[1] cmp $b->[1] } Spreadsheet::Read::rows($book- +>[1]); open my $fh, ">pl.csv"; my $csv = Text::CSV->new; $csv->eol("\r\n"); $csv->print($fh, $_) for @rows; close $fh;

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (2)
As of 2024-04-26 01:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found