Brothersoft.comWindows|Mac|Mobile|Games

|Message

Solve software problem quickly Share experience to help others Improve the ability of solving problem
How to Read CSV Files in Perl

11/09/2011 03:36 by LindaRodrigues

First answer posted by SandraMerz at 11/09/2011 03:36
Add Your Answer
10~1000 characters in length CAPTCHA:
2 Answers
  • SandraMerz
    1. Create a new text file in a text editor. Any text editor will do, including Windows Notepad, but the file should end with the ".pl" file extension and not ".txt" or ".rtf."

    2. Paste the following signature to the first line of the text file. Though not required, it helps if you distribute your work to others or forget later what language the script is using.

      #!/usr/bin/perl

    3. Add the following line to the text file to import the Perl CSV parsing library:

      use Text::CSV;

    4. Parse and print out the contents of a CSV file by pasting these lines:

      my $input = 'file.csv';

      my $parser = Text::CSV->new();

      open (CSV, "parse($_)) {

      my @columns = $parser->fields();

      print "@columns\n";

      }

      }

      close CSV;

      Replace 'file.csv' with the name of the CSV file to parse.

  • Was this answer helpful? 00 · 11/09/2011 03:36
  • Anonymous user
  • Here's the answer: http://www.linuxstall.com/read-csv-file-perl/
  • Was this answer helpful? 00 · 01/10/2012 08:21
Add Your Answer
10~1000 characters in length CAPTCHA:
Related Questions
Q:How Do I Disable the Chat Feature in Yahoo! Email?

A: Open the Yahoo! Mail website at Mail.Yahoo.com and sign in with your username and password. Click the "Available," "Busy" or "Invisible" l...(more)

Q:How to Convert PDF to SolidWorks

A: Download, install and open SolidWorks. Click "File" in the toolbar. It is located in the upper-left corner of the software window. Click...(more)

Q:How to Read a CSV File in ASP

A: Create an instance of the file system object. The file system object is a standard object within ASP that allows for the manipulation of fil...(more)

Q:How to Read a File Date

A:From Windows Explorer Click the "Start" Menu then click "Run" and type "explore" into the dialog box to open Windows Explorer. This will bri...(more)

Q:How to Read Last Log File From Solaris

A: Start Solaris by booting the computer and waiting for the operating system to load. Only administrators have access to lastlog functions, so...(more)

Added Successfully!

×

Are you sure to delete your answer?

NoYes

×

Are you sure to choose it as the best answer?

NoYes

×

Voted Successfully!

×

You can't vote for yourself

×

You can't choose your own answer

×