weectl import csv KeyError: 'source_field'

63 views
Skip to first unread message

tarob...@gmail.com

unread,
Apr 21, 2024, 12:27:22 PM4/21/24
to weewx-user
Hello,

I am trying to import some missing data via CSV file. I've done this numerous times pre weewx 5.0 and weectl (using wee_import). I've setup a new import config file using the new layout for [[FieldMap]]. I've attached the import config I used. However, during the --dry-run I am getting the below error. I've attached the config file.

Column Headings: 
['Timestamp','d5n1Temp', 'd5n1humid', 'd5n1Pres', 'rain5n1', 'windSpeed5n1',
       'windAvg', 'windDir', 'UV', 'luminosity', 'd5n1Humid', 'rain',
       'windSpeed', 'inTemp', 'inHumid', 'LiTemp', 'LiHumid', 'LiStrikes',
       'LiDistance', 'LiPres', 'GTemp', 'GHumid', 'radiation']

It's a source_field error but can't figure out which source_field is giving the error. I've looked them over but could be missing one.

sudo weectl import --import-config=/home/piToad/Documents/csv-import-weectl.conf --dry-run
Using configuration file /etc/weewx/weewx.conf
This is a dry run. Nothing will actually be done.
Starting weectl import...
Traceback (most recent call last):
  File "/usr/share/weewx/weectl.py", line 74, in <module>
    main()
  File "/usr/share/weewx/weectl.py", line 66, in main
    namespace.func(namespace)
  File "/usr/share/weewx/weectllib/__init__.py", line 121, in dispatch
    namespace.action_func(config_dict, namespace)
  File "/usr/share/weewx/weectllib/import_cmd.py", line 82, in import_func
    weectllib.import_actions.obs_import(config_dict,
  File "/usr/share/weewx/weectllib/import_actions.py", line 54, in obs_import
    source_obj = weeimport.weeimport.Source.source_factory(config_dict['config_path'],
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/share/weewx/weeimport/weeimport.py", line 316, in source_factory
    return get_object(module_class)(config_path,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/share/weewx/weeimport/csvimport.py", line 110, in __init__
    self.map = self.parse_map(_map,
               ^^^^^^^^^^^^^^^^^^^^
  File "/usr/share/weewx/weeimport/weeimport.py", line 551, in parse_map
    _mapped_source_fields = [config['source_field'] for field, config in _map.items()]
                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/share/weewx/weeimport/weeimport.py", line 551, in <listcomp>
    _mapped_source_fields = [config['source_field'] for field, config in _map.items()]
                             ~~~~~~^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/configobj/__init__.py", line 554, in __getitem__
    val = dict.__getitem__(self, key)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^
KeyError: 'source_field'
csv-import-weectl.conf

tarob...@gmail.com

unread,
Apr 21, 2024, 12:57:49 PM4/21/24
to weewx-user
Using my old import-csv.conf file (attached), I get the following error:

sudo weectl import --import-config=/home/piToad/Documents/csv-import.conf --dry-runUsing configuration file /etc/weewx/weewx.conf

This is a dry run. Nothing will actually be done.
Starting weectl import...
**** Unknown units 'unix-epoch' specified for field 'dateTime' in /home/piToad/Documents/csv-import.conf.
**** Nothing done, exiting.

csv-import.conf

tarob...@gmail.com

unread,
Apr 21, 2024, 1:02:12 PM4/21/24
to weewx-user
And I just realized what the issue was with the "Unknow units 'unix-epoch'". Changed units from 'unix-epoch' to 'unix_epoch' and now it seems to be working. My older "csv-import.conf" is now working with the weectl import.

gjr80

unread,
Apr 21, 2024, 3:59:13 PM4/21/24
to weewx-user
I think you will find this is the source of the error in your first post:

[[[inHumidity]]] source_field = inHumid unit = percent [[[windSpeed]]] source = windAvg unit = mile_per_hour [[[windDir]]] source_field = windDir unit = degree_compass

Gary
Reply all
Reply to author
Forward
0 new messages