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

New User

Feb 3, 2015, 9:25 AM

Views: 3532
csv2sqlite, Unknown Options

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/csv2sqlite.pm 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

Views: 3523
Re: [DavidBMcCoy] csv2sqlite, Unknown Options

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.