Importing lots of data points
-
Hi guys,
In the past I've seen a video (or couple of them) around here explaining how to import lots of data points using an excel + word combination.
I wanted to try that but I can't seem to find those videos anywhere anymore.Can someone give me a hand please?
Regards
Rodrigo -
I think this is the video you are thinking of but it is quite dated: http://infiniteautomation.com/forum/topic/1150/importing-large-numbers-of-data-points-from-an-excel-spreadsheet
I suggest you look at this for a better method: https://help.infiniteautomation.com/support/solutions/articles/14000022512-using-data-point-templates
-
I've also offered a few python scripts from time to time that can do this effectively. They're all based on having the base JSON for something and some kind of input (like a CSV or formula) to populate the JSON.
import json from StringIO import StringIO baseItem = """{"xid":"DP_12345", "name":"%(name)s", "someKey":"%(someValue)s"}""" csvFile = open("/path/to/csv") output = {"items":[]} for line in csvFile : data = line.replace("\r", "").replace("\n", "").split(",") output["items"].append( json.load( StringIO( baseItem % {"name": data[1], "someValue": data[2]} ) ) ) csvFile.close() outputFile = open("/path/to/output.json", "w+") outputFile.write(json.dumps(output, sort_keys=False, indent=4, separators=(",",": "))) outputFile.close()
-
I answer more than a month late, but thanks (better late, than never).
I'll check on your sugestions now.
Regards
Rodrigo -
Hi Joel,
In the video you recommended, you say that in a future video you are going to explain how to use CSV files to import lots of data points, you haven't made that video yet, right?
In this video you explain how to use the property template, I found this tool to be extremely useful, but my lack of imagination :) doesn't let me understand how to use that to import lots of data points, are you trying to tell me that I should create the points one by one, and use the property template to assign the same properties to all of them?Hi Phil
I thank you for your attempt to help me, but I know nothing about coding, so for me, what you wrote may well be chinese :$
I really appreciate your message though.Regards,
Rodrigo -
Looks like you are correct. I'll try to do a video on that soon. Basically, you can export a data source as csv using the csv icon on the data source page next to each data source. You can then modify the file and import the csv again on the Configuration Import Export page but be sure to change the drop down from json to csv when importing.
When importing csv you have to specify the xid of each data point and you also need to assign a template to each data point in the csv.
Hope that helps.
-
Thanks Joel, I'll try that, now I'm trying to use the json import export.
I have 70 fan coils on a building an each fan coil controller has 10 points or so, I created all the points for one controller, exported this in json format and now I'm modifying that file and adding the points of the rest, let's see how it goes.Regards,
Rodrigo -
@joelhaggar - This link no longer works.
-