| Mac-Apps-Seasonality-LoadICAOHistory documentation | view source | Contained in the Mac-Apps-Seasonality-LoadICAOHistory distribution. |
Mac::Apps::Seasonality::LoadICAOHistoryFromCSV - Load data from a CSV file into Seasonality's database.
This document describes Mac::Apps::Seasonality::LoadICAOHistoryFromCSV version 0.0.6.
use English qw{ -no_match_vars };
use Fatal qw{ open close read write };
use IO::File;
use DBI;
use Mac::Apps::Seasonality::LoadICAOHistoryFromCSV qw{ &load_icao_history_from_csv_handle };
use Mac::Apps::Seasonality::Exceptions;
my $file_handle = IO::File->new('data.csv', 'r');
my $database_connection =
DBI->connect(
"dbi:SQLite2:$database_file_name",
q{},
q{},
{
AutoCommit => 0,
RaiseError => 1,
}
);
eval {
load_icao_history_from_csv_handle(
$database_connection,
$file_handle,
clean => 1,
clean_message_handle => \*STDOUT,
)
};
my $exception
if ($exception = Mac::Apps::Seasonality::CSVParseException->caught()) {
...
} elsif ($exception = Mac::Apps::Seasonality::InvalidDatumException->caught()) {
...
} elsif ($EVAL_ERROR) {
...
} # end if
Provides functions for reading ICAO data from comma separated values (CSV) files.
%ALLOWED_UNITSThe set of presently allowed input units, keyed by
load_icao_history_from_csv_handle() option name.
load_icao_history_from_csv_handle($database_connection, $io_handle, %options)Takes a reference to a DBI handle and to an I/O handle referring to data in CSV format and loads the data from the handle into the database.
$database_connection must be an open handle to an SQLite2 database with
Seasonality's schema. This handle must have the RaiseError option set on it;
this module does no error checking of database actions on its own.
$io_handle must be an open handle to data in CSV format, with the data on
each line in the order described in the documentation for
"load_icao_history" in Mac::Apps::Seasonality::LoadICAOHistory. No checking
is done for I/O errors, so the use of the Fatal module is highly suggested.
The data read from this handle must not contain anything other than the actual
data to be loaded. In particular, this means that there cannot be any column
headers.
If no problems are encountered, the number of data points loaded is returned.
A Mac::Apps::Seasonality::CSVParseException is thrown if the raw input cannot
be turned into the module's internal representation.
A Mac::Apps::Seasonality::InvalidDatumException is thrown if an individual
value does not fit the constraints required by Seasonality.
A Mac::Apps::Seasonality::InvalidParameterException is thrown if one of the
options is not valid, e.g. if temperature_units is specified as 'kelvin'.
Options:
cleanA boolean value indicating whether "clean_icao_history_set" in Mac::Apps::Seasonality::LoadICAOHistory should be invoked after reading the file but before actually loading the data.
clean_message_handleA reference to a file handle to write any messages about cleaned up data to.
If clean is specified, but this is not, then the data will still be cleaned
but there be no indication of any problems found emitted.
temperature_unitsThe units that the temperature columns are in. Defaults to celcius.
pressure_unitsThe units that the pressure column is in. Defaults to hectopascals.
wind_speed_unitsThe units that the wind speed columns are in. Defaults to knots.
TODO
Mac::Apps::Seasonality::LoadICAOHistoryFromCSV requires no configuration files or environment variables.
None reported.
No bugs have been reported.
Please report any bugs or feature requests to
bug-mac-apps-seasonality-loadicaohistory@rt.cpan.org, or through the web
interface at http://rt.cpan.org.
Elliot Shank perl@galumph.com
Copyright ©2006-2007, Elliot Shank <perl@galumph.com>. All rights
reserved.
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See perlartistic.
BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR, OR CORRECTION.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENSE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
| Mac-Apps-Seasonality-LoadICAOHistory documentation | view source | Contained in the Mac-Apps-Seasonality-LoadICAOHistory distribution. |