in reply to Re^4: Splitting the records into multiple worksheets
in thread Splitting the records into multiple worksheets
Do you have any specific example of pulling the raw data into DB?
I've not had cause to use Sqlite as I usually have another DB available. But this is the sort of thing you need. Untested and without checking for errors creating connections and opening files etc. Hopefully it will give you a start.
use DBI; use DBD::Sqlite; # Connect to your database my $dbh = DBI->connect("dbi:sqlite:$db_name:localhost:$port", $db_user +, $db_password); # Create a temporary table $dbh->do("CREATE TEMPORARY TABLE IF NOT EXISTS ExcelData (name VARCHAR +(80), data INT)"); # Populate temporary table from your datasource foreach my $row(@responsetext) { my ($name, $data) = split / +/, $row $dbh->do("INSERT INTO ExcelData SET name = '$name', data = $data") +; } # Create a query to sort the data how you want it and output to CSV fi +le open $fh, '>', 'myfile.csv'; my $query = $dbh->prepare("SELECT name, data FROM ExcelData WHERE data + > 20 ORDER BY data"); $query->exceute; my ($n, $d); while (($n, $d) = $query->fetchrow_array) { print $fh qq["$n",$d\n]; } close $fh;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^6: Splitting the records into multiple worksheets
by hippo (Archbishop) on Feb 20, 2021 at 23:38 UTC | |
by Bod (Parson) on Feb 21, 2021 at 19:33 UTC | |
by marto (Cardinal) on Feb 21, 2021 at 21:22 UTC | |
by Bod (Parson) on Feb 21, 2021 at 23:54 UTC | |
by marto (Cardinal) on Feb 22, 2021 at 07:41 UTC | |
|
Re^6: Splitting the records into multiple worksheets
by chandantul (Scribe) on Feb 21, 2021 at 12:49 UTC | |
by marto (Cardinal) on Feb 21, 2021 at 13:07 UTC | |
by chandantul (Scribe) on Feb 25, 2021 at 04:57 UTC |