Re: DBD::CSV and skip_first_line
Jens Rehsack <[email protected]>
| Newsgroups | gmane.comp.lang.perl.modules.dbi.general |
|---|---|
| Organization | Comprehensive Perl Archive Network |
| Message-ID | <[email protected]> |
On 25.11.12 10:00, H.Merijn Brand wrote: > On Fri, 23 Nov 2012 17:43:50 -0500, "Scott R. Godin" <[email protected]> > wrote: > >> I've run into an issue where I need both col_names set and >> skip_first_line still set to TRUE, because of malformed colnames in the >> original dumpfiles that conflict with SQL Reserved Words (such as 'key') >> that I am unable to find any other acceptable workaround short of > > Why not automate the hacking using Text::CSV_XS and rewrite the header > before using DBD::CSV? Or simply quote the column names in your SQL statement? >> hacking the dumpfiles prior to import for unit-testing and validation >> prior to splitting the dumpfiles out into a normalized sql database. >> (I'll eed to hand this off to someone else for future dump-and-import >> work, so it's just got to WORK with these ACCESS database dump files >> as-is, plus HIPAA rules about not changing data complicates matters) >> >> Is there any way to ensure that despite col_names being set, I can still >> force skip_first_line => 1 ? or should I report this as a possible >> edge-case bug > > There should be, and it is likely that this case is already fixed in > the current development state of DBD::CSV by the valuable work of Jens > Rehsack, but that state is not (yet) releasable as it depends on > changes in SQL::Statement and DBI (DBD::File). Well, since we're both busy - we need to find an hour or so to integrate. I do not expect a general issue with DBI-1.622, I expect some edge cases we need to tidy up. >> to sum up, >> >> col names present in csv but bad (sql reserved words) >> can use col_names => [ @ary ], but this sets skip_first_line to FALSE as >> it *assumes* that colnames are NOT present in original dump >> >> what do ? :) > > Rewrite the headers with Text::CSV_XS before using DBD::CSV > Or simply quote the reserved cols :) Cheers -- Jens Rehsack