PDA

View Full Version : xml to csv converter for ted 5000




hotshotharry
Oct 5, 2009, 11:23 PM
I just wanted to share this applescript i made to convert the xml data that can be automatically downloaded to a csv format to be used in excel or numbers.

This file saves the newly formatted file as a last step, be sure to save it as a new file before you run it if you want to keep the original file!

To use this script you need to have the minutehistory.xml file open in textedit. Also you need to open system preferences go to universal access and enable access for assistive devices

If anyone has some advice on how to make this run in the background that would be great!



hotshotharry
Oct 5, 2009, 11:42 PM
This is an automator workflow that will download the xml data from the ted 5000 and save a copy to your desktop with time stamps. :)

Either you will need to change the ip address in the workflow to the address of your ted 5000 unit or change the ip address of your ted 5000 unit to 192.168.0.196

sparker
Nov 25, 2009, 01:09 PM
I just wanted to share this applescript i made to convert the xml data that can be automatically downloaded to a csv format to be used in excel or numbers.

This file saves the newly formatted file as a last step, be sure to save it as a new file before you run it if you want to keep the original file!

To use this script you need to have the minutehistory.xml file open in textedit. Also you need to open system preferences go to universal access and enable access for assistive devices

If anyone has some advice on how to make this run in the background that would be great!

Why not just create a shell script that uses wget to extract the .csv directly from the gateway (replace my IP with yours):

#---------- begin script get-ted-values ----------
echo "Getting values from TED"
_time=$(date +%Y%m%d-%H%M%S)

wget -O "CSV Files/Minutes-MTU0_$_time.csv" "http://10.0.30.6/history/minutehistory.csv?MTU=0&INDEX=0&U=1"
wget -O "CSV Files/Minutes-MTU1_$_time.csv" "http://10.0.30.6/history/minutehistory.csv?MTU=1&INDEX=0&U=2"

wget -O "CSV Files/Hourly-MTU0_$_time.csv" "http://10.0.30.6/history/hourlyhistory.csv?MTU=0&INDEX=0&U=3"
wget -O "CSV Files/Hourly-MTU1_$_time.csv" "http://10.0.30.6/history/hourlyhistory.csv?MTU=1&INDEX=0&U=4"


You can repeat the calls for secondhistory, dailyhistory, and monthlyhistory, and set the MTUs appropriately. I don't KNOW for a fact that the "U=1" numbers have to be sequential for each wget since each one will be in a separate session, but I did that in my script.

I just run the script in the background "get-ted-values &" (the ampersand forces it into the background), and a few seconds later, I have all the .csv files sitting in my directory. If you don't want to see the progress sliders as it works, add a "-a wget.log" option to each wget command that will "append" all that stuff into a wget.log file.

Steve