I have found and modded a perl script that converts a CSV file to an XML file. To get my not-quite flat file ready I use an Awk script:
awk ' {OFS=","}; $1~/^[***]/{next} $1~/^[A-Z]/{next} $1~/^--/{next} { printf "%4s,%4s,%3s,%13s,%5s,%10s,%5s,%10s,%-3s,%12s,%-3s +,%10s\n", $1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12 } ' input.txt > output.csv
It takes raw data files and add commas between columns. It is far from perfect as columns that are blank get shifted over which completely distorts my data: This
VOL TEST @VCC= 4.5V, VIL=2V, VIH=5.5V 5 796 6 533.0 mV,RNG1 60.00 mA,M100 + 5 801 493.0 m 0 500.0 m + 5 815 8 431.0 mV,RNG1 60.00 mA,M100 + 5 820 391.0 m 0 500.0 m
Becomes
5, 796, 6, 523.0,mV,RNG1, 60.00,mA,M100, 5, 801,483.0, m, 0, 500.0, m, , , <-t +he row closed ranks some how. 5, 815, 8, 418.5,mV,RNG1, 60.00,mA,M100, 5, 820,378.5, m, 0, 500.0, m, , ,
It would be nice to keep the heading, but it was messy and so I've learned to live without it. I hope Perl can do the job without distorting the data. Any help is greatly appreciated for I'm at a complete loss. My apologies about the formatting, I failed to read fully before posting and so assume that I was experiencing a serving error.

In reply to How to create an accurate CSV file by softserve

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.