So odd thing happens when I try to
weectl --import.
I dumped the data from the database I want to take it from (as well as the production one) via
sudo sqlite3 -header -csv /var/lib/weewx/weewx.sdb 'select * from archive where datetime >= 1742443200 and datetime <= 1742529600;' > 20th_pi4b8.csv
I copied both over to my PC and ran both of the output files through Excel to reconcile between the two, saving out a single 20th.csv with the data cleaned up as I want it to be. The schema/header and values are laid out exactly as my database schema is. The values are unmodified from the sqlite output, beyond copy/paste in Excel.
Copied that cleaned 20th.csv back to the production weewx pi, and ran:
pi@pi4b8:~/weeimport $ weectl import --import-config=/home/pi/weeimport/20th.conf --update --dry-run
Using configuration file /etc/weewx/weewx.conf
This is a dry run. Nothing will actually be done.
Starting weectl import...
A CSV import from source file '/home/pi/weeimport/20th.csv' has been requested.
Using database binding 'wx_binding', which is bound to database 'weewx.sdb'
Destination table 'archive' unit system is '0x01' (US).
Imported records will overwrite existing database records.
All WeeWX UV fields will be set to None.
All WeeWX radiation fields will be set to None.
This is a dry run, imported data will not be saved to archive.
Starting dry run import ...
Traceback (most recent call last):
File "/usr/share/weewx/weeimport/weeimport.py", line 856, in map_raw_data
_value = float(_row[self.map[_field]['source_field']].strip())
ValueError: could not convert string to float: ''
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/share/weewx/weectl.py", line 75, in <module>
main()
File "/usr/share/weewx/weectl.py", line 67, in main
namespace.func(namespace)
File "/usr/share/weewx/weectllib/__init__.py", line 90, in dispatch
namespace.action_func(config_dict, namespace)
File "/usr/share/weewx/weectllib/import_cmd.py", line 85, in import_func
weectllib.import_actions.obs_import(config_dict,
File "/usr/share/weewx/weectllib/import_actions.py", line 58, in obs_import
source_obj.run()
File "/usr/share/weewx/weeimport/weeimport.py", line 406, in run
_mapped_data = self.map_raw_data(_raw_data, self.archive_unit_sys)
File "/usr/share/weewx/weeimport/weeimport.py", line 904, in map_raw_data
self.map[_field]['unit'] == 'degree_compass':
File "/usr/lib/python3/dist-packages/configobj.py", line 554, in __getitem__
val = dict.__getitem__(self, key)
KeyError: 'unit'
I looked at the file in nano, and noticed it was saved in DOS format. I changed it to be not-DOS/Mac (...native then I guess?), but same result.
If I go in through
pi@pi4b8:~/weeimport $ sudo sqlite3 /var/lib/weewx/weewx.sdb
SQLite version 3.34.1 2021-01-20 14:10:07
Enter ".help" for usage hints.
sqlite> DELETE FROM archive WHERE datetime >= 1742443200 and datetime <= 1742529600;
sqlite> .mode csv archive
sqlite> .import 20th.csv archive
20th.csv:1: INSERT failed: datatype mismatch
20th.csv:1443: INSERT failed: datatype mismatch
sqlite> .quit
The data is in there though (and in the correct columns- no offset errors). Doing weectl database --rebuild-daily --date=2025-03-20 rebuilds successfully. That said, my graphs look... off, where the data is highly variable in it's 10-min interval that the graph uses for plot points. You can see it's very smooth once I'm back to using directly captured data.
Current (trailing 24hr):
Yesterday (00:00-23:59)
The sqlite output for 'select datetime,outTemp from archive...;' for Mar-20 13:30-15:30 (imported data) and Mar-21 13:30-15:30 (direct) have a similar number of missing records for the outTemp and the extraTemp/extraHumid observations, but the imported data has 'epochtime,""' in a csv output for the blank records, where the direct's csv output is just 'epochtime,'
The graphs are being generated (with a 10-minute resolution) very differently. If I take a 10-min period of records:
-the graph point for the imported data is the sum of the 10 records, divided by 10, even though 8 were actually recorded- averaging in every blank as a 0
-the graph point for my direct observations, the same period also had blanks, but the average was taken of the records present.
I imagine everything in the background is likewise factoring what are meant to be blanks, as zeros.
So, the sqlite import added "" for blank records to the database it would seem. Before I go even more leeroy jenkins on my database, what do I need to do? Go do it again, but add/insert None for every blank observation? add/insert "" for every blank? Or better, what am I not seeing/missing in my weectl import that it's erroring out?
Here is the first two lines of the csv file I'm trying to import for context:
pi@pi4b8:~/weeimport $ head -2 20th.csv
dateTime,usUnits,interval,altimeter,appTemp,appTemp1,barometer,batteryStatus1,batteryStatus2,batteryStatus3,batteryStatus4,batteryStatus5,batteryStatus6,batteryStatus7,batteryStatus8,cloudbase,co,co2,consBatteryVoltage,dewpoint,dewpoint1,ET,extraHumid1,extraHumid2,extraHumid3,extraHumid4,extraHumid5,extraHumid6,extraHumid7,extraHumid8,extraTemp1,extraTemp2,extraTemp3,extraTemp4,extraTemp5,extraTemp6,extraTemp7,extraTemp8,forecast,hail,hailBatteryStatus,hailRate,heatindex,heatindex1,heatingTemp,heatingVoltage,humidex,humidex1,inDewpoint,inHumidity,inTemp,inTempBatteryStatus,leafTemp1,leafTemp2,leafWet1,leafWet2,lightning_distance,lightning_disturber_count,lightning_energy,lightning_noise_count,lightning_strike_count,luminosity,maxSolarRad,nh3,no2,noise,o3,outHumidity,outTemp,outTempBatteryStatus,pb,pm10_0,pm1_0,pm2_5,pressure,radiation,rain,rainBatteryStatus,rainRate,referenceVoltage,rxCheckPercent,signal1,signal2,signal3,signal4,signal5,signal6,signal7,signal8,snow,snowBatteryStatus,snowDepth,snowMoisture,snowRate,so2,soilMoist1,soilMoist2,soilMoist3,soilMoist4,soilTemp1,soilTemp2,soilTemp3,soilTemp4,supplyVoltage,txBatteryStatus,UV,uvBatteryStatus,windBatteryStatus,windchill,windDir,windGust,windGustDir,windrun,windSpeed,pm4_0,pm4_0out,pm2_5out,pm1_0out,pm10_0out,co2out
1742443200,1,1,30.13063837,62.49347962,,30.12772479,0,1,1,1,1,,,,604.5454057,,1106,1500,58.65679821,,,59,57,58,40,51,,,,72.61,72.37,72.47727273,78.30909091,76.82,,,,,,,,61.1239978,,,,67.94440487,,56.89523489,54,74.66,1,,,,,,,,,,,0,,,,,92,60.999998,1,,2.8,0.6,1.6,30.04971646,,0,0.88889,0,,,,,,,,,,,20.12999882,1,,,,,45.88235294,,,,70.7,,,,,1,,,1,60.999998,202.5,2.678862144,202.5,0.038218048,2.293082881,2.4,,2,,2,