Yield from within map function

Hi there,
i have a list of locations, based on this i want to receive weatherdata from an api and rewrite it back to influxdb.

lat:         long:       topic:
45.12     11.33      Teststation1
46.12     11.33      Teststation2

i try it with map but it does not do anything. it seems that i cant do this pipeforward with the new table
inside the map function. Is there any way to archive something like this?

   |> map(fn: (r) => 
        url = "https://somewatherapi"
        csvresponse= string(v:requests.get(url: url).body)
        csvtable=csv.from(csv: csvresponse, mode: "raw")
          |> experimental.unpivot()
          |> to(bucket: "testdata")

            return {
              url: csvresponse,
   |> yield(name: "custom-name")

May with this script its better to notice what iam tryin to do
The Problem is that the new measurement “testt99” is never inserted into the bucket testdata

import "array"

getweather = (lat, lon,topic) =>  {
  array.from(rows: [{_time:now() ,_measurement: "test99",_field:"value", _value:99}]) 
  |> to(bucket: "testdata2")

    //only to return something 
    exampleVar = 44.0
    return exampleVar
array.from(rows: [{_time:now() ,lat: "44.12",lon:"13", topic:"Station 1"},{_time:now() ,lat: "4.12",lon:"13", topic:"Station 2"}])
  |> map(fn: (r) =>({ r with testret: getweather(lat:r.lat,lon:r.lon,topic:r.topic) }))
  |> yield(name: "custom-name")

Hello @automationsloesung,
I’m not sure. I tried your script and its working for me.

I did notice that I was having trouble viewing the results when I opened two tabs though and didn’t silence the one with your script. See the eye is crossed out. I query for the test99 data in the second tab “Query 2”.
That part was weird. But the data is definitely there.
How are you querying for your test99 data after you query with that script?

Hi Anaisdg,

thanks for evaluating this. Weird… i tryied it again, but i cant query the inserted data.
could this be version related that its working in your environment? I am running InfluxDB v2.6.1.

attached screenshot as how i try to query the data.

inserting the data:

query for the data: - closed the whole browser and reconnect to the dbinterface to prevent caching problems

Hi there, any idea what i also can try to get this work?


Hmm… still no idea why it worked in your environment, but not in mine. Do you have any further ideas about this?
regards automationsloesung