Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: CSV headers. Feedback wanted

by duelafn (Parson)
on Feb 10, 2016 at 14:47 UTC ( [id://1154868]=note: print w/replies, xml ) Need Help??


in reply to CSV headers. Feedback wanted

I like the idea. My comments:

  • Take separators as a key/value pair so that as other auto-detectable features are added they can be configured as well.
  • The auto-detectable features should have reasonable defaults (you have default separators, this is just formalizing that I agree it should be so, but add tab to the default separators).
  • The auto-detectable features should be disableable (perhaps via something like no_eol => 1).
  • Don't force lower-case.
  • I'd suggest a more obnoxious name so that it is clear that it is a magical routine. Perhaps autoconfigure_from_header.

A quick skim of the documented options suggests the following candidates for auto-detection: BOM (encoding), eol, quote, escape_char, allow_whitespace (set only), allow_loose_quote (set only), allow_loose_escapes (set only), quote_empty. Several of those will be undeterminable from just the header (in which case should remain as default), but if detected should set the parameter.

Good Day,
    Dean

Replies are listed 'Best First'.
Re^2: CSV headers. Feedback wanted
by Tux (Canon) on Feb 10, 2016 at 15:33 UTC
    • key/value pairs: I think I agree, but having the thing being used most like as suggested fits better with the other methods. Nothing carved in stone yet, though
    • defaults. Once the API stabalized, I'll add them more clearly
    • auto-detect. Good thought. All auto-detection on, and disable with key/value options. I like that
    • lower case will be the default, but casing can be another option none/lc/uc/tc
    • auto_header? autoconfigure_from_header seems like getting to high an expectation level
    • BOM: yes, definitely
    • eol: no. though possible, it is useless, as readline will only read a line that already is covered by the default eol setting (undef)
    • quote: unreliable. will cause surprises
    • escape: unreliable. will cause surprises
    • allow_whitespace: possibly harmful. If the header contains spaces around the separators, it is likely the data will also have it, but that is not vice-versa.
    • allow_loose_quote: no (see allow_whitespace)
    • allow_loose_escapes: no (see allow_whitespace)
    • quote_empty: no, it is very unlikely a header contains empty fields. If it does, using this new functionality will only cause more trouble than it is worth

    Enjoy, Have FUN! H.Merijn

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1154868]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (4)
As of 2024-03-19 07:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found