Skip to content

just sample perl code that parses xlxs files and loads to mysql/mariadb

Notifications You must be signed in to change notification settings

ericparlin/sample-code

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 

Repository files navigation

sample-code

just sample perl code that parses xlxs files and loads to mysql/mariadb.
Initial commit written in just a couple hours but will be adding to it.
If you are using a csv file, just open it in Excel and export as xlsx.

Dependancies:
DBI - perl db interface
DBD::mysql - mysql driver (should work on MariaDB as well)
SQL::Abstract - to dynamically assign placeholders; sanitize sql input without the need for static statement structures
Getopt::Long - to...get options
Spreadsheet::XLSX - for xlsx parsing and determining input data types
Text::Iconv - converter for xlsx data
List::MoreUtils - for iterating over array elements in chunks
Data::Dump::Streamer (to debug data structures)

Usage example: init.pl --file F:\data_load.xlsx --database testdb --table testtable --user eparlin --pw pass --host 192.168.201.132 --port 3306
The host and port args are optional. If you are on localhost you can omit them

TODO: Add support/drivers for Postgres, SQLite, and newer MariaDB driver.
Add usage output.
Add sanitization test package.
Add newline sanitization back in.
Make use of already existing data type detection from xsxl to better tailor sql column data types.

About

just sample perl code that parses xlxs files and loads to mysql/mariadb

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages