in reply to Importing text files with DBI
Curious if there are modules to import delimnited text into, say, mysql (didn't find much on CPAN). Something like this, where $dbh is a DBI object linked to some database:
$schema=<<EOF; `Name` VARCHAR(32) PRIMARY KEY, `Address` VARCHAR(256) NOT NULL, `Phone` VARCHAR(16) NOT NULL, `Comment` VARCHAR(80) EOF importTextIntoDBI( $dbh, 'myTable.txt', delimiter=>"\t", tableName=>'myTable', schema=>$schema, firstline=>2, # Skip header checkMissing=>[0..2], # Make sure first 3 columns are not missing, checkPattern=>[undef,undef,$phoneRegexp,under] # Check formats );
There's Text::Delimited for example, but I didn't see support for missing values and format checking. Maybe there are other modules that do the parsing, checking, etc, on a delimited file to create a "clean" object that's ready to be imported into DBI?
|
|---|