Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: Importing text files with DBI

by RockM66 (Novice)
on Nov 23, 2013 at 16:39 UTC ( [id://1064043]=note: print w/replies, xml ) Need Help??


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?

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1064043]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (2)
As of 2024-04-20 11:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found