Config

The problem

I tried using Spreadsheet::XLSX::Reader::LibXML to read the spreadsheet, but it takes 2.5 hours to read the whole thing. So I decided to manually convert the XLSX file to a tab separated file (TSV) and read the TSV instead. It's faster reading the TSV but this also doesn't work because some cells contain embedded carriage returns (which Excel allows) but which messes up the TSV file. So a single row in the XLSX file appears as multiple rows in the TSV file. Like this:
col1<tab>col2<tab>col3 with embedded returns<tab>col4<tab>col5
So when I read the CSV file I read it directly into an array like this:
# Open file here @csv=<$CSVFILE>; chomp(@csv);
I simply don't have time to go through 100,000 lines each time I get a new XLSX file to fix broken lines with embedded CRLF.

Questions

  1. Is there a way to speed up reading the XLSX file directly?
  2. Or is there a Linux util that can convert an XLSX file to a TSV while removing embedded carriage returns from each cell?
  3. When reading the XLSX file I'm currently reading each row cell by cell using $cell=$worksheet->get_cell($row,$col). I didn't see a method to return a whole row at at time.
  4. I'm currently researching how to replace all chr(10) and chr(13) in Excel with blanks. Then I'll convert the XLSX to TSV.
Thank you!

In reply to Convert XLSX to TSV and remove CRLF in cells by bulrush

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.