Closed gjr80 closed 7 years ago
I changed the json.dump invocation to: json.dump(data, f, separators=(',', ':'), sort_keys=True) This reduces the number of spaces in the output.
You could include or ignore the sort_keys, I like it because I find it easier to read the output files with predictable ordering.
Thanks, don't know how I missed the separators parameter. Implemented at commit https://github.com/gjr80/weewx-realtime_gauge-data/commit/0c8fd4a13032d35a0ba3b04dcd44e6c6f38a4038
Whitespace typically makes up about 10% of the gauge-data.txt contents, whilst the file size is small the (potential) frequency of upload means a significant amount of data could be saved from unnecessary transfer.
json.dump()
is used to create the JSON string, and that results in whitespace. Applying.replace(" ","")
to the JSON string would remove the spaces but would also corrupt any forecast text. Applying.replace(": ",":")
followed by.replace(", ",",")
would be safe to the forecast text but you need to traverse the string twice. Or maybe we just leave it as is.