Hi guys:

This is my work assignment. I can really use some good advices right now.

I have a ASCII file can be opened with Notepad, and this file have 4500 columns of plain text data. I also have another file called layout file in CSV format gives me the layout information of the ASCII file.

Here is a piece of the layout file:

Respondent.Serial,Serial number,,,,

Type: Long,,,,,

,,,,Card: 0,Cols: 1-8

As you can see this information show from column 1-8 of the ASCII file, is the data called Serial number.

I just need to use comma to separate the columns of the ASCII file by using the correct column index from the layout file, and also at the top of the new data CSV file also have to the proper name of that piece of data, in this case is the Serial number.

I don't want do spend a week to align this ASCII file, which only have 450 something rows manually. And of cause if I don't write some codes this time, next time this kind data given to me again, I will again suffer. There are about 1000 commas I have add for each row of the ASCII file.

Appreciate all your knowledge and thoughts

Zli034


In reply to Please help me with this ASCII file parsing assignment by zli034

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.