Show Data Point Name as Column in Watch List CSV Download
-
We created a watch list that select data points based on tags and its functioning exactly as we need, however, we have some usability problems with the way the CSV download file is created.
When we do CSV download separate value columns the column header is the XID which is not useful.
Also the time step of the data seems to change based on the duration of time data is selected for.
Our desired function would have to use tags to select data points. Then be able to download the data at high resolution and have the column header be DataPointName, or preferably DeviceName - DataPointName.
Any thoughts on how to get the CSV formatted like this would be great.
Thanks in advance.
-
Hi chio,
Currently this option does not exist, but it would be pretty easy to use a JSON export and a python script to rewrite the file something like...
import json configFile = open("/path/to/config.json", encoding='utf-8') config = json.load(configFile) configFile.close() csvData = open("/path/to/data.csv", "r") xidLine = csvData.readline() # Assume no commas, quotes or newlines in the XIDs xids = xidLine.replace("\r", "").replace("\n", "").replace("\"", "").split(",")[1:] #print(xids) xidMap = {} for dp in config["dataPoints"] : xidMap[dp["xid"]] = dp newFirstLine = "\"timestamp\"" for xid in xids : newFirstLine += ",\"" + xidMap[xid]["deviceName"] + " - " + xidMap[xid]["name"] + "\"" newFirstLine += "\n" #print(newFirstLine) outputFile = open("/path/to/output.csv", "w+") outputFile.writelines(newFirstLine) outputFile.writelines(csvData.readlines()) outputFile.close() csvData.close()
Definitely we see what you're saying and that you've added weight in the discussion that the available formats could be more flexible. I think the original XIDs as headers was done in anticipation of providing a multicolumn data upload, but no such feature exists currently.
I have created a git issue about it: https://github.com/infiniteautomation/ma-core-public/issues/1436
-
@phildunlap
Hi, Phil
I am glad that I have found this post which has expressed the exact same issue I will have with the heading format.
In some of our projects, we may have to generate hundreds of reports. I understand the solution you suggested can work on occasions that only have
a handful of meters.
There is no update on the GitHub about the enhancment.
Barring an up-coming enhancement in the near future, would you recommend me use a custom XID instead of the one generated by Mango to overcome this issue? for example, I could name an XID as 'METER-1_KWH'. Does Mango software check the uniqueness of XID when it is entered? If it does, I think entering XID by hand can be a solution to this.Thanks.
-
Hi cwangv,
Barring an up-coming enhancement in the near future, would you recommend me use a custom XID instead of the one generated by Mango to overcome this issue? for example, I could name an XID as 'METER-1_KWH'. Does Mango software check the uniqueness of XID when it is entered? If it does, I think entering XID by hand can be a solution to this.
I have personally always believed in custom XIDs, and have always encouraged people to think of them as another identifier field. Others disagree with me, and I haven't been able to understand the reasoning presented. Something about more work if it has to change later? I can't say.
Yes Mango checks the uniqueness of the XID. You could generate XIDs for all the points and update them via SQL, or if it's a fresh system you could use JSON import, but since neither CSV nor JSON import can change an XID, you must use the SQL console or change them by hand, which would be the more work to change later argument. But, it'll make the data download more readable without having to wait for the git issue to be addressed, and it'll make any dashboards' code more legible.