Hello! I’m having to work on some fields that contain white spaces. When I ran into this issue before, I just dropped the measurement, replaced all of the whitespaces with underscores and started over. I really don’t want to do that again and am hoping to find a solution. I’ve tried escaping the whitespace with a backslash like below with no luck.
from(bucket: "telegraf/autogen")
|> range(start: dashboardTime)
|> filter(fn: (r) => r._measurement == "PM03" and r._field == "Primary system power")
|> map(fn: (r) => ({r with _value: (r.Primary\ system\ power * .001732)}))
Hi there,
Interestingly enough I had a similar issue when collecting data from my Jetson device. Though it does not specifically answer your question I believe we can bypass the issue altogether.
Here is an example:
In this case when using the map function we specify the new column name (in my case tempMod). Secondly we specify the r._value column as this is where the value we want to modify is stored.
Thank you, Jay!
This definitely answers my question for a single field.
I do have some scenarios where there are multiple fields with whitespace I need to combine. Do you have any ideas on this? Below is an example:
|> map(fn: (r) => ({ r with _value: r.USI1 UPS225 1 POWER + r.USI1 UPS225 2 POWER + r.USI1 UPS250 1 POWER PHA + r.USI1 UPS250 1 POWER PHB + r.USI1 UPS250 1 POWER PHC}))
This is actually one where I went in and dropped the entire measurement record, replaced all of the whitespace with underscores and restarted. It was painful, but I’m slowly grinding my way up the learning curve!
As you can see we do the following in this example:
We first filter by the _field names we would like to use in our calculation. Note: You do not need to store your result in a variable like I have. I have purely done this to highlight the part of interest (pivot and map)
Next we can perform a pivot on the table which will transform our _field names into columns.
Lastly we perform our map function. After a little digging I found out you can define your recored notation like so r["column name"] , which means white spaces within your column names should no longer be an issue.