Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW

comment on

( [id://3333] : superdoc . print w/replies, xml ) Need Help??

I think my recent changes to csv2xlsx warrants an update.

As this is on github but not yet released, feel free to comment on the new -S/--split feature, so I can update the docs or amend the code.

To explain the new options: I was faced with a 50_000 line CSV file that had logical vertical sections. The section start was clearly marked. Say you have a CSV file with orders per customer, grouped by customer, and every such section starts with Customer,34526,"Foo Tool Factory",20220601,... followed by the orders.

What I wanted was to convert this CSV to Excel (as required by the other end) where each customer had its own sheet. With the new options that would be:

$ csv2xlsx -S A=Customer --sl=C orders.csv

Start a new sheet when column A is "Customer" and then use the value in column C for the matching record as label for the sheet.

-S (or --split) also supports syntax for regex/empty/undef/compare and can be stacked.

Here are the highlights of changes since my previous posts:

1.49 - 2022-06-21

  • csv2xlsx --split=CxP [--split-label=C]
  • Full documentation/manual for csv2xlsx

1.48 - 2022-05-24

  • kh => 1 (use internal headers)
  • Add constants for META flags (RT#142508)
  • Export :CONSTANTS
  • Fix sep_set typo (issue 37)

1.47 - 2021-12-21

  • Make error 2014 catchable
  • Suppress empty lines on empty input (issue 34)

1.46 - 2021-03-24

  • New attribute comment_str (RFC 4180-bis)
  • New attribute skip_empty_rows (RFC 4180-bis)
  • http -> https in links in docs
  • Fix several issues with auto-detecting \r as EOL

1.45 - 2020-12-24

  • Allow adding to existing data in csv (out => $ref)
  • examples/csv2xlsx : -L # to limit records to export
  • examples/csv2xlsx : --de # for possible double-encoding fix
  • Add examples/csv-split
  • examples/csv2xlsx : Check if .xlsx is creatable before conversion

Enjoy, Have FUN! H.Merijn

In reply to Re: The future of Text::CSV_XS - TODO by Tux
in thread The future of Text::CSV_XS - TODO by Tux

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

  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.