CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

Home: Perl Programming Help: Intermediate:
csv2sqlite, Unknown Options


New User

Feb 3, 2015, 9:25 AM

Post #1 of 2 (3559 views)
csv2sqlite, Unknown Options Can't Post

Hello All,

I am attempting to run the following code to parse out a csv file, change the date format, and export as a sqlite file in a database called appy. See below:


rm appy
for f in *.csv; do tail -n +2 $f >>appy; done
rm appy.sqlite
perl /Users/davidbmccoy/Perl\ Modules/App-csv2sqlite-0.004/bin/csv2sqlite -l "default_column_type = 'CHAR(255)'" -l "columns=\
[['Rank'],['Accession','INTEGER PRIMARY KEY'],['MRN'],['Dept'],['Proc'],['Priority'],['Readby'],\
['Signedby'],['Addendum'],['Read','DATE'],['Signed','DATE'],['Reason'],['Result'],['Impression'], ['dup']]" \
-l no_header=1 \
-l 'map_rows=sub{no strict; \
use 5.010; \
use feature "state"; \
use DateTime::Format::Strptime; \
state $dt=DateTime::Format::Strptime->new(pattern=>"%m/%d/%Y%t%I:%M:%S%t%p"); \
$_[0][9]=$dt->parse_datetime($_[0][9])->datetime(); \

return $_[0]; \
}' appy appy.sqlite

I am getting the following error:
Unknown options: default_column_type at /Library/Perl/5.16/App/ line 140.
}fileappycsv_optsHASH(0x7f83a986a628)columns[['Rank'],['Accession','INTEGER PRIMARY KEY'],['MRN'],['Dept'],['Proc'],['Priority'],['Readby'],['Signedby'],['Addendum'],['Read','DATE'],['Signed','DATE'],['Reason'],['Result'],['Impression'], ['dup']]default_column_type 'TEXT'no_header1sfgh-3416:~

Was hoping someone could help me out. Thanks so much.

Veteran / Moderator

Feb 3, 2015, 11:57 AM

Post #2 of 2 (3550 views)
Re: [DavidBMcCoy] csv2sqlite, Unknown Options [In reply to] Can't Post

It would help if you format your code so that it's readable.

Take bash out of the picture and write a proper and clean perl script and DON'T disable strict.


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives