Hi all, I've recently been using DBD::CSV in my ongoing job of cleaning up horrible public record data. Well, this is the first time i've tried to write csv tables (files) using DBD::CSV, and i've found quite a strange (to me) situation that may have something to do with the quote() method, and may have something to do with the actual writing of the record. In any case, heres my original approach which leads to strange results, and my workaround:

original approach - strange result
I issue this query, which i generated using a csv db handle quote method on all values being inserted:

INSERT INTO snames VALUES ( '797000','140740413000','KNAACK, RICHARD I +','GRANTEE','5403','','W','','SUNNYSIDE','DR','112N','','','MEQUON',' +WI','53092' )
And the result in the data file is:
797000,140740413000,"HAGEN, RONALD",GRANTOR,5403,'?5?W?6?SUNNYSIDE?7?D +R?8?112N?9?MEQUON?10?WI?11?53092'
I get no error of any sort, and i do have PrintError and RaiseError set, and am executing the query in an eval block. Note that things go fine until that first empty field (empty string). Then i get that strange last column, the numbers correspond to numbering the columns, and the data is there too, with the question marks in between. I have the csv_sep_char as a comma, and the csv_quote_char as double quote.


Fixed approach, but why:
If i change all the empty string values to a single space and then DBD::CSV quote() them, then everything behaves as i'd expect, and the rows get written as they should. For the insert as above, heres what ends up in the file:
797000,140740413000,"HAGEN, RONALD",GRANTOR,5403," ",W," ",SUNNYSIDE,D +R,112N," "," ",MEQUON,WI,53092

Is this a problem with a version of some support lib, such as SQL::Statement, or am i just expecting something other than what is supposed to happen?

In reply to DBD::CSV quote() oddity by shemp

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.