Export Hierarchy Config as CSV Would be Very Useful
-
If we could get the hierarchy exported into excel as a csv then it would be very useful in replicating and generating the record structure for very large projects.
The current methodology of externally converting json to csv and back again is extremely difficult to work with successfully. We have a project with 306 devices each with 50 points and it would be useful to generate the hierarchy in excel with properly tagged xid's for import.
Any suggestions on achieving this welcomed!! -
I agree, this would be a very helpful feature. Here is a python script that might help you in the mean time. It takes a CSV file with up to 4 folders deep and turns it into a point hierarchy json.
The 2-3 folder columns can be empty. make sure the csv is sorted first by folder 1 column, then 2, 3 and 4 so they are all grouped together.
The device name column isn't used just helpful for reference.
https://www.dropbox.com/s/qh6syeso3flk9ss/CSVtoJSONpointHierarchy.zip
On your command line navigate into the folder with the csv and script and run the script like: "python csvtojson-pointHierarchy.py" and you will get a file called output.json
-
@joelhaggar said in Export Hierarchy Config as CSV Would be Very Useful: I tried this but the script generated this error ? Is my format correct?
C:\CONVERT>python csvtojson-pointHierarchy.py
Traceback (most recent call last):
File "csvtojson-pointHierarchy.py", line 49, in <module>
folderDict[prevPath]["points"].append(data[4])
KeyError: ''Folder 1 Folder2 Foulder3 Foulder4 xid Device Name
VUZE Tenant Sub-Metering Unit-101
Admin DP_Com1_101-00315
DP_Com1_101-00391
DP_Com1_101-00392
DP_Com1_101-00414
DP_Com1_101-00560
DP_Com1_101-00578
DP_Com1_101-00611
DP_Com1_101-00899
DP_Com1_101-00902
DP_Com1_101-00905
DP_Com1_101-00962
DP_Com1_101-00998
Heating DP_Com1_101-00110
DP_Com1_101-00310
DP_Com1_101-00311
DP_Com1_101-00312
DP_Com1_101-00313
DP_Com1_101-00314
DP_Com1_101-00316
DP_Com1_101-00335
DP_Com1_101-00336
DP_Com1_101-00510
DP_Com1_101-00532
DP_Com1_101-00533
DP_Com1_101-00534
DP_Com1_101-00535
DP_Com1_101-00540
DP_Com1_101-00572
DP_Com1_101-00574
DP_Com1_101-00575
DP_Com1_101-00576
DP_Com1_101-00577
DP_Com1_101-00612
DP_Com1_101-00613
DP_Com1_101-00928
DP_Com1_101-00938
DP_Com1_101-00960
DP_Com1_101-00961
DP_Com1_101-00969
DP_Com1_101-01110
Potable Water DP_Com1_101-00334
DP_Com1_101-00910
DP_Com1_101-00912
DP_Com1_101-00920
DP_Com1_101-00922
DP_Com1_101-00924
DP_Com1_101-00926
Unit-102 Admin DP_Com1_102-00315
DP_Com1_102-00391 -
You need the folder 1, 2, 3 & 4 for every row / xid. You should not have any blank folder 1 folders.
-
OMG It worked beautifully thanks Joel. :)
-
@phillip-weeks Hi Joel.. I imported the hierarchy perfectly into our R&D ES but using the same hierarchy json file for the production ES
produces no confirmations or errors however it does not update the hierarchy structure either.
Both ES servers are running the same mango versions and have the same data point structures imported from the same data,
I have re-tried importing and even restarted mango and reimported but each time it behaves the same.
What should I look for as the possible cause of such a behaviour?
Thanks in advance -
That's interesting. I'd check the ma.log file. Also what UI are you using? I would try the both the legacy and the new UI for JSON import and see if you have any difference.
-
Is there some length limit to the json? because I tried uploading the output.json as well as drag and dropping the file into UI of both new ES servers... the import window remained blank and at 0% for 15 minutes until I cancelled it. However, using the legacy method one ES server imports the json correctly as I can paste right into the window which I can't seem to do in the new UI.
-
Interestingly I replicated my Data sources and re-imported the json with a different prefix tag on the DS and DP id's and the hierarchy did import into the second server this time so I suspect I some error on the original Data source setup because I had some original issues with the import and a couple property templates missing. When I originally created the data source some points got left out because the property template was not in the new system at that point and I did not realize this and imported the hierarchy which expected these points and did complain about missing points, which I then added in a smaller import. the legacy hierarchy import didn't work after that point. The new UI import never worked at all. All good now! , somehow (magically) all data sources slotted into the correct hierarchy after the last json import which had the prefix on the point ids.