Script to convert recorded Heartrate Data for Sporttracks (Updated)
2 posters
Script to convert recorded Heartrate Data for Sporttracks (Updated)
In my Holidays I had some problems with the gps reception and returned from my workouts with nice Heartrate statistics, but without gps trackpoints. I searched a way to import the heartrate data track to an activitiy in Sporttracks.
It can be imported with the "Edit Data Tracks" dialog. So i wrote a VBScript to convert the Heartrate Data generated by Oruxmaps to the csv format that Sporttracks need.
The Script is in early stage and not really userfriendly, but it works. Save the code in a file called "OruxHR2CSV.vbs" (the .vbs is the important thing) and place it in the same folder as your gpx files. Then start the Command Prompt (cmd.exe) and execute the script with the filename as argument (for example: OruxHR2CSV.vbs test.gpx). The Script creates a csv file called like the gpx in the same folder.
Hope it works for you, maybe i can improve it further.
I'm a noob in programming, so I look forward for your suggestions.
UPDATE: Only worked in main directories (C:\, D:\, ...)
UPDATE2: Fixed the Script and added some error handling.
It can be imported with the "Edit Data Tracks" dialog. So i wrote a VBScript to convert the Heartrate Data generated by Oruxmaps to the csv format that Sporttracks need.
The Script is in early stage and not really userfriendly, but it works. Save the code in a file called "OruxHR2CSV.vbs" (the .vbs is the important thing) and place it in the same folder as your gpx files. Then start the Command Prompt (cmd.exe) and execute the script with the filename as argument (for example: OruxHR2CSV.vbs test.gpx). The Script creates a csv file called like the gpx in the same folder.
Hope it works for you, maybe i can improve it further.
I'm a noob in programming, so I look forward for your suggestions.
- Code:
Set WshShell = Wscript.CreateObject("WScript.Shell")
Set Arg = Wscript.Arguments
Set FSO = CreateObject("Scripting.FileSystemObject")
Set net = Wscript.createObject("Wscript.network")
Dim gpxsrc, scriptpath, start, ende, data, erste, r, Text, action
if Arg.count < 1 Then
msgbox "Place the Script in the folder of your gpx files and execute the Script with the filename as argument."
WScript.Quit
End if
gpxsrc = Arg.item(0)
if InStr(1, gpxsrc,".gpx") = 0 Then
msgbox "The Sourcefile has to be a gpx file!"
WScript.Quit
End if
scriptpath = FSO.getparentfoldername(Wscript.ScriptFullName)
Lesen(scriptpath&"\"&gpxsrc)
start = InStr(1, Text, "<om:bpm")+68
ende = InStr(start, Text, "</om:bpm>")
if ende-start < 1 Then
msgbox "The Sourcefile contains no heartrate data created by oruxmaps."
WScript.Quit
End if
data = Split(Mid(Text, start, ende - start), "Z")
ReDim Preserve erg(Ubound(data)+2)
'erste Zeile
erste = Replace(Split(data(0)," ")(1),"T"," ")
erg(0) = "Seconds;Value"
erg(1) = "0"&";"&Split(data(0)," ")(0)
for r=1 to Ubound(data)-1
erg(r+1) = DateDiff("s",erste,Replace(Split(data(r)," ")(1),"T"," "))&";"&Right(Split(data(r)," ")(0),Len(Split(data(r)," ")(0))-1)
Next
Schreiben(Join(erg, VbCrLF))
msgbox "Converted "&scriptpath&"\"&gpxsrc&" to "&scriptpath&Replace(gpxsrc,".gpx","")&".csv. Script finished successfully."
'-------------------------------------------------------------------------------
Sub Schreiben (WText)
'-------------------------------------------------------------------------------
Set File = fso.OpenTextFile(scriptpath&"\"&Replace(gpxsrc,".gpx","")&".csv", 2, True)
File.Write(WText)
File.Close
End Sub
'-------------------------------------------------------------------------------
Sub Lesen (Datei)
'-------------------------------------------------------------------------------
Dim FileNow, a, b
Set a = fso.GetFile(Datei)
b = a.Size
Set f = fso.OpenTextFile(Datei, 1, True)
Text = f.Read(b)
f.Close
End Sub
UPDATE: Only worked in main directories (C:\, D:\, ...)
UPDATE2: Fixed the Script and added some error handling.
Last edited by BerniPi on Mon Mar 26, 2012 7:04 am; edited 6 times in total (Reason for editing : PostIt (orux))
BerniPi- Cantidad de envíos : 26
Fecha de inscripción : 2011-05-24
Localización : Austria
Re: Script to convert recorded Heartrate Data for Sporttracks (Updated)
TheAbalone wrote:In my Holidays I had some problems with the gps reception and returned with nice Heartrate statistics, but without gps trackpoints. I searched a way to import the heartrate data track to an activitiy. It can be imported with the "Edit Data Tracks" dialog. So i wrote a VBScript to convert the Heartrate Data generated by Oruxmaps to the csv format that Sporttracks need.
The Script is in early stage and not really userfriendly, but it works. Save the code in a file called "OruxHR2CSV.vbs" (the .vbs is the important thing) and place it in the same folder as your gpx files. Then start the Command Prompt (cmd.exe) and execute the script with the filename as argument (for example: OruxHR2CSV.vbs test.gpx). The Script creates a csv file called like the gpx in the same folder.
Hope it works for you, maybe i can improve it further.
I'm a noob in programming, so I see forward to your suggestions.
Thanks, TheAbalone;
Interesting...
orux
orux- Cantidad de envíos : 3946
Fecha de inscripción : 2009-07-06
Re: Script to convert recorded Heartrate Data for Sporttracks (Updated)
Thank YOU orux, for this great app and all the work you put into it. This Script adds also the possibility to use Oruxmaps to track Indooractivities. I know, it's kind of strange to use a GPS-tracking-map app indoors, but who cares
theabalone
theabalone
BerniPi- Cantidad de envíos : 26
Fecha de inscripción : 2011-05-24
Localización : Austria
Re: Script to convert recorded Heartrate Data for Sporttracks (Updated)
Updated the Script. Should work now , although nobody complained yet
BerniPi- Cantidad de envíos : 26
Fecha de inscripción : 2011-05-24
Localización : Austria
Similar topics
» 2.8.0 IN THE MARKET (updated)
» NEW VERSION 1.1.0 BETA [UPDATED TO 1.1.4BETA]
» Support of CH1903 Datum
» Average Speed only from recorded track during moving
» NEW BETA 1.7.4! [v1.8.0 uploaded to the market]
» NEW VERSION 1.1.0 BETA [UPDATED TO 1.1.4BETA]
» Support of CH1903 Datum
» Average Speed only from recorded track during moving
» NEW BETA 1.7.4! [v1.8.0 uploaded to the market]
Permissions in this forum:
You cannot reply to topics in this forum
|
|