I have a CSV file that needs to through two seperate processes (in the end there will be 2 files (Dload.unl and Tload.unl and we'll say the input file name is mass.csv). I have a processfile() function that will call the process Dload funtion. In Dload I want to read mass.csv into Dload and then do the following:


1. remove the 6th element in the array (or the last column)

2.validate the format is mm/dd/yy

3.validate that elements 0-4 are NOT NULL

4.write @line to Dload.unl seperated by pipes (with a pipe at the end of the line)


In Tload I want to read mass.csv into Tload and then do the following:

1. Add 3 columns to the file with the following information in each column:

- @output[0] = 0

-@output1 = Today's Date (in the format 2007-11-07 00:00:00)

-@output2 = "A"

2.write @line to Dload.unl seperated by pipes (with a pipe at the end of the line)


Thanks in advance, I really appreciate it.


Here is an example of the input file:

0,2007,A,MassLd,7,106,212,314,81,y,

0,2008,B,MassLd,8,107,213,315,82,x,

0,2009,C,MassLd,9,108,214,316,83,z,

0,2006,D,MassLd,6,109,215,317,84,u,

If you need anything else just let me know or have any questions on it. S


In reply to Parsing CSV file and validation by dolo21taf

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.