Module FunctionDef arguments args NameParam NameParam NameParam defaults body TryExcept body Assign NameStore SubscriptLoad NameLoad Index NameLoad handlers ExceptHandler type NameLoad body Assign NameStore SubscriptStore NameLoad Index NameLoad Call NameLoad Return NameLoad decorator_list Import alias ClassDef bases NameLoad body Expr Str FunctionDef arguments args NameParam NameParam NameParam NameParam NameParam NameParam NameParam NameParam defaults NameLoad NameLoad body Assign AttributeStore NameLoad attr NameLoad Assign AttributeStore NameLoad attr NameLoad Assign AttributeStore NameLoad attr NameLoad Assign AttributeStore NameLoad attr Num Assign AttributeStore NameLoad attr NameLoad Assign AttributeStore NameLoad attr NameLoad Assign AttributeStore NameLoad attr NameLoad Assign AttributeStore NameLoad attr Dict decorator_list FunctionDef arguments args NameParam defaults body Return BinOpMod Str TupleLoad AttributeLoad AttributeLoad NameLoad attr attr AttributeLoad NameLoad attr decorator_list FunctionDef arguments args NameParam NameParam NameParam NameParam NameParam NameParam defaults body If CompareNotEq NameLoad AttributeLoad NameLoad attr body Assign NameStore Call AttributeLoad NameLoad attr NameLoad If BoolOpOr BoolOpAnd CompareIsNot AttributeLoad NameLoad attr NameLoad CompareLt NameLoad AttributeLoad NameLoad attr BoolOpAnd CompareIsNot AttributeLoad NameLoad attr NameLoad CompareGt NameLoad AttributeLoad NameLoad attr body Pass orelse Print BinOpMod Str TupleLoad AttributeLoad NameLoad attr Call AttributeLoad NameLoad attr NameLoad NameLoad NameLoad NameLoad Return Assign NameStore Call NameLoad AttributeLoad NameLoad attr Call AttributeLoad NameLoad attr NameLoad NameLoad NameLoad NameLoad Expr Call AttributeLoad NameLoad attr NameLoad decorator_list FunctionDef arguments args NameParam defaults body Expr Str For TupleStore NameStore NameStore Call AttributeLoad AttributeLoad NameLoad attr attr body Expr Call AttributeLoad AttributeLoad NameLoad attr attr keyword NameLoad keyword AttributeLoad NameLoad attr keyword BinOpDiv Call NameLoad NameLoad Call NameLoad NameLoad decorator_list decorator_list Assign NameStore Call NameLoad Str FunctionDef arguments args NameParam NameParam NameParam NameParam NameParam NameParam NameParam NameParam NameParam defaults body Expr Str Import alias Assert Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad BinOpMod Str NameLoad ImportFrom alias Import alias Assign NameStore ListLoad FunctionDef arguments args NameParam defaults body Return Lambda arguments args NameParam NameParam NameParam defaults Call NameLoad NameLoad NameLoad keyword NameLoad keyword NameLoad keyword AttributeLoad NameLoad attr keyword NameLoad keyword NameLoad decorator_list Assign NameStore Dict Assign NameStore ListLoad For TupleStore NameStore NameStore Call NameLoad NameLoad Call NameLoad Call NameLoad NameLoad body Expr Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad If CompareNotEq NameLoad Str body If CompareIn NameLoad TupleLoad Str Str Str body Assign SubscriptStore NameLoad Index BinOpAdd NameLoad Str NameLoad orelse TryExcept body Assign NameStore Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad Str handlers ExceptHandler type NameLoad body Raise Call NameLoad BinOpMod Str TupleLoad NameLoad Call AttributeLoad Str attr Call NameLoad AttributeLoad Str attr Call AttributeLoad NameLoad attr orelse If NameLoad body Expr Call AttributeLoad AttributeLoad NameLoad attr attr BinOpAdd BinOpAdd Str AttributeLoad NameLoad attr Str Expr Call AttributeLoad Call NameLoad CompareGt AttributeLoad NameLoad attr Num attr Expr Call AttributeLoad NameLoad attr TupleLoad Call NameLoad NameLoad NameLoad For NameStore TupleLoad Str Str Str body Assert CompareIn BinOpAdd NameLoad Str NameLoad BinOpMod Str NameLoad Assign NameStore ListLoad If CompareIsNot NameLoad NameLoad body Expr Call AttributeLoad NameLoad attr CompareGtE AttributeLoad NameLoad attr NameLoad If CompareIsNot NameLoad NameLoad body Expr Call AttributeLoad NameLoad attr CompareLtE AttributeLoad NameLoad attr NameLoad If UnaryOpNot NameLoad body Assign NameStore NameLoad orelse Import alias Assign NameStore Call NameLoad AttributeLoad NameLoad attr NameLoad Assign NameStore Call NameLoad Call AttributeLoad Call NameLoad NameLoad attr If NameLoad body For NameStore NameLoad body Assign NameStore AttributeLoad NameLoad attr Expr Call AttributeLoad AttributeLoad NameLoad attr attr BinOpAdd Call NameLoad NameLoad Str Assign NameStore Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad BinOpMod BinOpAdd BinOpAdd NameLoad Str NameLoad NameLoad If UnaryOpNot Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad body Expr Call AttributeLoad AttributeLoad NameLoad attr attr BinOpMod Str NameLoad orelse Assign NameStore ListLoad For TupleStore NameStore NameStore NameLoad body Expr Call AttributeLoad NameLoad attr TupleLoad Call NameLoad keyword NameLoad keyword NameLoad keyword AttributeLoad NameLoad attr NameLoad Expr Call NameLoad NameLoad Call NameLoad NameLoad NameLoad NameLoad Expr Call AttributeLoad NameLoad attr orelse Expr Call AttributeLoad AttributeLoad NameLoad attr attr Str decorator_list FunctionDef arguments args NameParam NameParam NameParam NameParam defaults body Expr Call AttributeLoad AttributeLoad NameLoad attr attr BinOpMod Str TupleLoad NameLoad NameLoad NameLoad NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam NameParam defaults body For TupleStore NameStore NameStore NameLoad body Expr Call AttributeLoad NameLoad attr NameLoad NameLoad NameLoad NameLoad keyword NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam NameParam NameParam NameParam defaults body TryExcept body Assign NameStore Num Assign NameStore NameStore NameStore NameLoad For NameStore Call AttributeLoad Call NameLoad NameLoad Str attr body If NameLoad body Assign NameStore Call AttributeLoad NameLoad attr NameLoad If CompareGt Call AttributeLoad NameLoad attr Num body TryExcept body Assign NameStore AttributeLoad NameLoad attr Assign NameStore Call NameLoad Call NameLoad NameLoad Assign NameStore Call NameLoad Call NameLoad NameLoad Assign NameStore Call NameLoad Call NameLoad NameLoad If CompareEq NameLoad NameLoad body If CompareEq NameLoad NameLoad body If CompareEq NameLoad NameLoad body Expr Call AttributeLoad AttributeLoad NameLoad attr attr BinOpMod Str Call NameLoad NameLoad NameLoad NameLoad orelse Assign NameStore NameLoad Assign NameStore NameLoad Assign NameStore NameLoad Expr Call NameLoad NameLoad NameLoad NameLoad Call NameLoad GeneratorExp TupleLoad NameLoad Call NameLoad NameLoad comprehension TupleStore NameStore NameStore NameLoad handlers ExceptHandler type NameLoad name NameStore body Expr Call AttributeLoad AttributeLoad NameLoad attr attr BinOpMod Str TupleLoad NameLoad NameLoad AugAssignAdd NameStore Num For TupleStore NameStore NameStore NameLoad body Expr Call AttributeLoad NameLoad attr handlers ExceptHandler body Expr Call AttributeLoad AttributeLoad NameLoad attr attr BinOpAdd NameLoad Str Raise decorator_list FunctionDef arguments args NameParam defaults body Import alias Import alias Assign NameStore Call AttributeLoad NameLoad attr keyword Str keyword SubscriptLoad NameLoad Index Num keyword Str Expr Call AttributeLoad NameLoad attr Str keyword NameLoad keyword Str Expr Call AttributeLoad NameLoad attr Str keyword Str Expr Call AttributeLoad NameLoad attr Str keyword NameLoad keyword NameLoad keyword Str Expr Call AttributeLoad NameLoad attr Str keyword NameLoad keyword NameLoad keyword Str Expr Call AttributeLoad NameLoad attr Str keyword Str keyword Str Expr Call AttributeLoad NameLoad attr Str keyword Str keyword Str Expr Call AttributeLoad NameLoad attr Str keyword Str keyword Str Expr Call AttributeLoad NameLoad attr Str keyword Str keyword Str Expr Call AttributeLoad NameLoad attr Str keyword NameLoad keyword Str keyword Str Assign NameStore Call AttributeLoad NameLoad attr SubscriptLoad NameLoad Slice Num Assign NameStore Dict For TupleStore NameStore NameStore Call AttributeLoad AttributeLoad NameLoad attr attr body If UnaryOpNot Call AttributeLoad NameLoad attr Str body Assign SubscriptStore NameLoad Index NameLoad NameLoad Expr Call NameLoad NameLoad decorator_list If CompareEq NameLoad Str body Import alias Expr Call AttributeLoad NameLoad attr Call NameLoad AttributeLoad NameLoad attr
N/A get_or_create N/A N/A dict key creator N/A N/A N/A N/A N/A value N/A dict N/A key N/A N/A N/A KeyError N/A N/A value N/A dict N/A key N/A creator N/A value N/A N/A sys Readings N/A object N/A N/A Stores a set of readings for a single place __init__ N/A N/A self sample_table place_id missing_data_marker converter year_month_to_month_number maximum minimum N/A None None N/A N/A N/A self sample_table sample_table N/A N/A self missing_data_marker missing_data_marker N/A N/A self maximum maximum N/A N/A self minimum 0 N/A N/A self converter converter N/A N/A self place_id place_id N/A N/A self year_month_to_month_number year_month_to_month_number N/A N/A self aggregated_values N/A N/A __repr__ N/A N/A self N/A N/A N/A N/A %s for place %i N/A N/A N/A self sample_table _tablename N/A self place_id N/A add_reading N/A N/A self year month day reading out_of_range N/A N/A N/A N/A reading N/A self missing_data_marker N/A N/A reading N/A N/A self converter reading N/A N/A N/A N/A N/A self minimum None N/A reading N/A self minimum N/A N/A N/A self maximum None N/A reading N/A self maximum N/A N/A N/A N/A N/A %i,%i,%f N/A N/A self place_id N/A N/A ClimateDataPortal year_month_day_to_day_number year month day reading N/A N/A readings N/A get_or_create N/A self aggregated_values N/A N/A self year_month_day_to_day_number year month day list N/A N/A N/A readings append reading N/A done N/A N/A self N/A N/A N/A Writes the average reading to the database for that place and month N/A N/A day_number values N/A N/A N/A self aggregated_values iteritems N/A N/A N/A N/A N/A self sample_table insert time_period month_number place_id N/A self place_id value N/A N/A sum values N/A len values N/A N/A N/A ClimateDataPortal N/A local_import ClimateDataPortal import_tabbed_readings N/A N/A folder start_station end_station suffix prefix fields clear_existing_data separator missing_data_marker N/A N/A N/A 
    Expects a folder containing files with name rtXXXX.txt
    
    each file contains lines of the form e.g.:
1978	1	1	0	-99.9	-99.9

representing year, month, day, rainfall(mm), minimum and maximum temperature
     N/A os N/A N/A N/A N/A os path isdir folder N/A %s is not a folder! folder decimal Decimal N/A datetime N/A field_order N/A readings_lambda N/A N/A sample_table N/A N/A N/A N/A N/A N/A missing_data_marker converter place_id N/A N/A Readings sample_table place_id missing_data_marker missing_data_marker converter Decimal year_month_to_month_number N/A ClimateDataPortal year_month_to_month_number maximum None minimum None N/A N/A date_format N/A N/A field_positions N/A N/A N/A field position N/A zip fields N/A range N/A len fields N/A N/A N/A N/A N/A sys stderr write field N/A N/A field UNUSED N/A N/A N/A field N/A year month day N/A N/A N/A date_format N/A N/A field _pos position N/A N/A N/A N/A sample_table N/A N/A N/A ClimateDataPortal SampleTable matching field O N/A N/A N/A KeyError N/A N/A N/A Exception N/A '%s' not recognised, available options are: %s
You can add new tables using add_table.py N/A field N/A N/A ,  join N/A map N/A "%s" __mod__ N/A N/A available_tables keys N/A N/A clear_existing_data N/A N/A N/A N/A N/A sys stderr write N/A N/A Clearing  N/A sample_table _tablename N/A N/A N/A N/A db N/A N/A sample_table id 0 delete N/A N/A N/A field_positions append N/A N/A readings_lambda sample_table position N/A field N/A year month day N/A N/A N/A N/A field _pos date_format N/A %s is not specified in --fields field N/A query_terms N/A N/A N/A start_station None N/A N/A N/A N/A query_terms append N/A N/A climate_station_id station_id start_station N/A N/A end_station None N/A N/A N/A N/A query_terms append N/A N/A climate_station_id station_id end_station N/A N/A query_terms N/A N/A query climate_station_id N/A N/A operator N/A query N/A reduce N/A operator and_ query_terms N/A stations N/A list N/A N/A N/A db query select N/A stations N/A N/A station stations N/A N/A station_id N/A station station_id N/A N/A N/A N/A sys stderr write N/A N/A str station_id N/A data_file_path N/A N/A N/A os path join folder N/A N/A N/A prefix %04i suffix station_id N/A N/A N/A N/A N/A os path exists data_file_path N/A N/A N/A N/A N/A sys stderr write N/A %s not found
 data_file_path N/A N/A variable_positions N/A N/A N/A field position field_positions N/A N/A N/A N/A variable_positions append N/A N/A field missing_data_marker missing_data_marker converter Decimal place_id N/A station id position N/A N/A import_data_in_file data_file_path N/A tuple variable_positions separator date_format N/A N/A N/A db commit N/A N/A N/A N/A N/A sys stderr write No stations! Import using import_stations.py
 N/A out_of_range N/A N/A year month day reading N/A N/A N/A N/A N/A N/A sys stderr write N/A %s-%s-%s: %s out of range
 N/A year month day reading N/A import_data_row N/A N/A year month day data N/A N/A N/A N/A variable field_string data N/A N/A N/A N/A variable add_reading year month day field_string out_of_range out_of_range N/A import_data_in_file N/A N/A data_file_path variable_positions separator year_pos month_pos day_pos N/A N/A N/A N/A N/A line_number 1 N/A last_year last_month last_day None N/A line N/A N/A N/A open data_file_path r readlines N/A N/A line N/A N/A field_strings N/A N/A line split separator N/A N/A N/A N/A field_strings __len__ 0 N/A N/A N/A N/A field N/A field_strings __getitem__ N/A year N/A int N/A field year_pos N/A month N/A int N/A field month_pos N/A day N/A int N/A field day_pos N/A N/A day last_day N/A N/A N/A month last_month N/A N/A N/A year last_year N/A N/A N/A N/A N/A sys stderr write N/A Duplicate record for %s N/A str year month day N/A N/A last_year year N/A last_month month N/A last_day day N/A N/A import_data_row year month day N/A tuple N/A N/A variable N/A field position N/A N/A variable position variable_positions N/A N/A N/A Exception N/A exception N/A N/A N/A N/A N/A sys stderr write N/A line %i: %s
 N/A line_number exception N/A line_number 1 N/A N/A variable position variable_positions N/A N/A N/A N/A variable done N/A N/A N/A N/A N/A N/A N/A sys stderr write N/A line N/A N/A main N/A N/A argv N/A N/A N/A argparse N/A os N/A parser N/A N/A argparse ArgumentParser description Imports observed climate data from tab-delimited files in a folder. prog N/A argv N/A 0 usage 

<web2py preamble to run script> \
  %(prog)s \
  --folder path_to/folder [options]

Use flag -h | --help for extra help on options.

The file names must follow a convention of prefix + station_id + suffix.
  e.g.: 
  path_to
  `--folder
     |--rt0100.txt
     |--rt0101.txt
     |--...
     `--rt9999.txt

  * Other files in this folder will not be read.
  * Files not corresponding to imported stations will not be read.
  * You must add tables for the data being import before it can be imported. 
    Use add_table.py to do this.

Examples: *(IN ROOT OF APP FOLDER)*

  Import all files in a folder, clearing existing data :

    python ./run.py \
      %(prog)s \
      --folder path_to/folder --clear_existing_data \
      --fields year month day "Rainfall mm" "Max Temp C" "Min Temp C"

  Import a range of stations:

    python ./run.py \
      %(prog)s \
      --folder path_to/folder --from 0 --to 500 \
      --fields year month day "Rainfall mm" "Max Temp C" "Min Temp C"

  Only import Rainfall:

    python ./run.py \
      %(prog)s \
      --folder path_to/folder \
      --fields year month day "Rainfall mm" UNUSED UNUSED
 N/A N/A N/A parser add_argument --folder required True help Folder in which to search for files. N/A N/A N/A parser add_argument --clear_existing_data help Truncate database tables first. N/A N/A N/A parser add_argument --start_station type int default None help Station number to start from. N/A N/A N/A parser add_argument --end_station type int default None help Station number to end on 
        (inclusive, i.e. import data from this station's file too). N/A N/A N/A parser add_argument --prefix default rt help File name prefix e.g. '%(default)s' (default) N/A N/A N/A parser add_argument --suffix default .txt help File name suffix e.g. '%(default)s' (default). N/A N/A N/A parser add_argument --separator default help Field separator e.g. '	' (default). N/A N/A N/A parser add_argument --missing_data_marker default -99.9 help Missing data marker. 
        Interpret this as missing data and do not import anything for that date.
         N/A N/A N/A parser add_argument --fields required True nargs + help List of fields in file, e.g.:
        year month day "Rainfall mm" "Max Temp Celsius" "Min Temp Celsius"
        year, month and day are used to parse the date.
        The other fields name tables to import data into, mapping by position.
        All fields must be accounted for. Any unused fields should be marked as UNUSED.
         N/A args N/A N/A parser parse_args N/A argv N/A 1 N/A kwargs N/A N/A N/A key value N/A N/A N/A args __dict__ iteritems N/A N/A N/A N/A N/A key startswith _ N/A N/A N/A kwargs N/A key value N/A N/A import_tabbed_readings kwargs N/A N/A N/A __name__ __main__ N/A N/A sys N/A N/A N/A sys exit N/A main N/A sys argv