Ok that sure looks like it would do the job but with my file format I would
need to use "," as a delimiter between records rather than a new line
something like (borrowed from another similar utility). I have never done
Python so I'm a little lost on how to change this sorry

with open(self.filename) as f:
for line,row in enumerate(f.readlines()):
if line == 0:
names = row.strip().split(",")
if line == 0:
units = row.strip().split(",")







On Wed, Apr 24, 2019 at 1:40 AM Thomas Keffer <[email protected]> wrote:

> Because of the syntax, it's tempting to look at a ConfigObj file and think
> of it as assigning the right hand side to the left hand side. But, it's
> really not. It's a mapping. The left hand side *maps to* the right hand
> side.
>
> As a key:value comes in from the file, we need to know what to do with the
> key. Given a key, what WeeWX name do we assign it to? With a mapping, we
> look it up, then do the assignment to the value. If we did it the other way
> around, we'd have to search all the *values* in the mapping to find what
> it should be mapped to. That's backwards from the way dictionaries work.
>
> -tk
>
> On Tue, Apr 23, 2019 at 5:51 AM Andrew Milner <[email protected]>
> wrote:
>
>> Tom
>> Forgive me for being a pedant - but shouldn't the label map for filepile
>> have the arguments the other way round
>> ie rather than
>>  myVoltage = Supply Voltage
>> it should be
>>  SupplyVoltage = myVoltage
>> ie
>>   weewx destination field = source data field
>>
>> normally left of equals sign is the result of operations right of equals
>> sign
>> eg
>>   a = 3 + 2 would put 5 into a
>>
>>
>>
>> On Tuesday, 23 April 2019 14:45:38 UTC+3, Thomas Keffer wrote:
>>>
>>> Take a look at Filepile <https://github.com/tkeffer/filepile>. It may
>>> do what you want, or help you write your own.
>>>
>>> -tk
>>>
>>> On Mon, Apr 22, 2019 at 7:43 PM <[email protected]> wrote:
>>>
>>>> Hi all
>>>>
>>>> I have devised a method to export my Air Quality Data (AQI) from my
>>>> Arduino based weather station to Weewx (it can't be sent via the usb port
>>>> with the rest of the data). It involves sending the data via a UDP
>>>> broadcast packet from the station, this is then captured by a small Python
>>>> script on my Weewx Pi and written to a txt file.
>>>>
>>>> The txt file data looks like this
>>>> AQI25=5.50,AQI100=4.10,AQIIndex=22,AQICO2=967
>>>>
>>>> From the Weewx wiki I have crafted the beginning of a service to import
>>>> the data to my Wewwx database (extended with the 4 new data fields) but I'm
>>>> not sure how to complete that task. So far I have this, which I think will
>>>> grab the first value - how do I parse the other 3? Is it as simple as just
>>>> adding more lines such as event.record['AQI100'] = float(value) etc?
>>>>
>>>> *import* syslog
>>>>
>>>> *import* weewx
>>>>
>>>> *from* weewx.wxengine *import* StdService
>>>>
>>>>
>>>> *class* WDAQIService(StdService):
>>>>
>>>>     *def** __init__*(self, engine, config_dict):
>>>>
>>>>         super(WDAQIService, self).__init__(engine, config_dict)
>>>>
>>>>         d = config_dict.get(*'WDAQIService'*, {})
>>>>
>>>>         self.filename = d.get(*'filename'*, *'/home/pi/AQIData.txt'*)
>>>>
>>>>         syslog.syslog(syslog.LOG_INFO, *"WDAQIImport: using %s"* %
>>>> self.filename)
>>>>
>>>>         self.bind(weewx.NEW_ARCHIVE_RECORD, self.read_file)
>>>>
>>>>
>>>>     *def** read_file*(self, event):
>>>>
>>>>         *try*:
>>>>
>>>>             *with* open(self.filename) *as* f:
>>>>
>>>>                 value = f.read()
>>>>
>>>>             syslog.syslog(syslog.LOG_DEBUG, *"WDAQIImport: found value
>>>> of %s"* % value)
>>>>
>>>>             event.record[*'AQI25'*] = float(value)
>>>>
>>>>         *except* Exception *as* e:
>>>>
>>>>             syslog.syslog(syslog.LOG_ERR, *"WDAQIImport: cannot read
>>>> value: %s"* % e)
>>>>
>>>> Thanks
>>>> Colin
>>>>
>>>> --
>>>> You received this message because you are subscribed to the Google
>>>> Groups "weewx-user" group.
>>>> To unsubscribe from this group and stop receiving emails from it, send
>>>> an email to [email protected].
>>>> For more options, visit https://groups.google.com/d/optout.
>>>>
>>> --
>> You received this message because you are subscribed to the Google Groups
>> "weewx-user" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected].
>> For more options, visit https://groups.google.com/d/optout.
>>
> --
> You received this message because you are subscribed to the Google Groups
> "weewx-user" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"weewx-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to