NAME

Weather::Underground::StationHistory - Utility functions for dealing with weather station historical data from http://wunderground.com.

VERSION

This document describes Weather::Underground::StationHistory version 1.0.5.

SYNOPSIS

use Weather::Underground::StationHistory qw{ :all };

use LWP::Simple;

print
    strip_garbage_from_station_history(
        get(
            generate_single_day_station_history_url(
                'KILCHICA52',
                2006,
                10,
                27,
            )
        )
    );

DESCRIPTION

This module provides a URL generator function for retrieving historical data for weather stations from Weather Underground (http://wunderground.com).

Additionally, a function to clean up the data retrieved from said URLs is provided. Nominally, the content retrieved from the URLs is in CSV (Comma Separated Values) format. If you enter these URLs into a web browser, the data does appear to be in that format. However, the MIME type given for the data by the web server is text/html and the data contains <br> tags and HTML comments (though no <html>, <head>, or <body> tags that you would expect for an HTML document). Thus, if a user copies and pastes the data from the web browser, the application receiving the data will get correct CSV, but anything trying to directly parse the page content as CSV will encounter problems.

INTERFACE

generate_single_day_station_history_url($station_id, $year, $month_number, $day_of_month)

Returns the URL to use for retrieving data for the station on the specified day.

$year needs to be the full year number; two digit years are not supported.

$month_number needs to be in the range 1 to 12.

strip_garbage_from_station_history($original_contents)

Takes a string containing the data retrieved from Weather Underground and returns a string containing the same data, without the standard problematic content.

Note: this function does not ensure that the data is in valid CSV format. It merely removes extraneous text that usually causes problems in parsing.

The returned value has lines delimited by whatever your platform translates "\n" to, which may be different from what Weather Underground is returning.

DIAGNOSTICS

None.

CONFIGURATION AND ENVIRONMENT

Weather::Underground::StationHistory requires no configuration files or environment variables.

DEPENDENCIES

Regexp::Common

INCOMPATIBILITIES

None reported.

BUGS AND LIMITATIONS

No bugs have been reported.

Please report any bugs or feature requests to bug-weather-underground-stationhistory@rt.cpan.org, or through the web interface at http://rt.cpan.org.

SEE ALSO

Weather::Underground for retrieving current conditions.

AUTHOR

Elliot Shank <perl@galumph.com>

LICENSE AND COPYRIGHT

Copyright (c) 2006-2008, 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.

DISCLAIMER OF WARRANTY

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.