Results 1 to 4 of 4

Thread: How to Parse CSV file using PERL

  1. #1
    Join Date
    Apr 2009
    Posts
    68

    How to Parse CSV file using PERL

    I have a bit of an issue trying to obtain some data from a csv file using PERL. I am trying to write a perl program which parses CSV files, and inserts the data into the DB. The problem is that i need to parse csv files which have fields spanning multiple lines. My script is placed in /usr/local. Can anyone here suggest me which rules should I keep in mind to parse CSV files.

  2. #2
    Join Date
    Apr 2008
    Posts
    193

    Re: How to Parse CSV file using PERL

    CSV is a comma separated value data file is a physical ASCII file structure that contains records whose values are delimited or separated by commas. Traditionally CVS also uses optional double quotes around the values, and then, depending on which wicked version of Excel it's supposed to be incompatible with, more or less insane conventions for values with double quotes in them. CSV is a common file type which can be imported into spreadsheet applications such as MS-Excel, database applications such as MS-Access, and contact databases such as MS-Outlook, ACT, Goldmine, etc. The Text::CSV module provides functions for both parsing and producing CSV data.

  3. #3
    Join Date
    Jan 2009
    Posts
    140

    Re: How to Parse CSV file using PERL

    When you are developing across platforms for a client that insists 'modules' are not allowed, and the perl program must be totally self contained.I guess the actual problem is that you are comparing the lines before throwing out the fields you don't want to include in the comparison. you find the reasoning for the way I explained the solution. CSV is one implementation of a delimited text file, which uses a comma to separate values (where many implementations of CSV import/export tools allow an alternate separator to be used;

  4. #4
    Join Date
    Jan 2009
    Posts
    99

    Re: How to Parse CSV file using PERL

    I tried hand earlier in the day and was able to download and install the module. And it worked well too. But now i have to parse the XML file instead of csv. I guess the actual problem is that you are comparing the lines before throwing out the fields you don't want to include in the comparison. The simplest solution would be to read the uploaded file line-by-line and splitting the lines by commas, but this is not fool proof, just in case the one of the fields contain a comma which is not a delimiter but a part of the dataBefore you print, copy the print value to a hash, and if the hash already contains the value, don't print.

Similar Threads

  1. Replies: 6
    Last Post: 13-07-2010, 12:29 AM
  2. Does java parse large text file
    By Zeverto in forum Software Development
    Replies: 3
    Last Post: 30-07-2009, 01:26 PM
  3. Powershell script to parse system logs in text file
    By SADIQ in forum Operating Systems
    Replies: 2
    Last Post: 02-06-2009, 07:05 PM
  4. Batch Script Text file parse
    By tator.usenet@gmail.com in forum Windows Server Help
    Replies: 5
    Last Post: 25-03-2009, 02:12 AM
  5. Batch Script to parse lines in text file
    By jntoner1@gmail.com in forum Windows Server Help
    Replies: 8
    Last Post: 28-01-2009, 04:38 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,714,054,857.83092 seconds with 17 queries