Welcome Guest Search | Active Topics
How to import a training log Options · View
12HonzaDe
Posted: 28 Feb 10


Posts: 5
Location: Czech Republic
Guys, I'm new here, but I like very much!
My problem is that it's end of February and I have quite some existing info in my training log. I wonder, if there is any way how to import basic stuff into your system. [that would be great to analyze all data here]
I can imagine that there would be some excel or csv file with a given format (date, starts, length,...) that can be uploaded and imported into my training log.
It would be wonderful, if anything like that exists. I am hesitant to click day-by-day every activity :), maybe there is a smart way to get data in..
lease, let me know if any option like that exists....

Tnx! 12:)
Hollywoof
Posted: 28 Feb 10


Posts: 4,379
Location: United Kingdom
Hi Honza

What format do you have already? Is it Excel?

If so, can you write any code at all? e.g. something like VBA?

If you can then I think we can work out some example code to allow you to upload things :)

Stuart

If you like the site: become a facebook fan, rate us on SportTracks, and talk about us everywhere!
12HonzaDe
Posted: 28 Feb 10


Posts: 5
Location: Czech Republic
Hi Stuart,

yes, it is excel, yes, I can do some easy not complicated VBA:), or my students could help me..:)..

Really, it would be great and i believe i am not only one appearing here late in the year..:).

Cheers, 12:)
Hollywoof
Posted: 28 Feb 10


Posts: 4,379
Location: United Kingdom
OK - had a quick look...

And everything changes - so which version of Excel - XP, 2003, 2007, 2010? Also, do you have any other tools installed - e.g. programming tools like Visual Studio?

Sorry for so many questions - but looks like Microsoft have changed things between different versions of Excel.

If you like the site: become a facebook fan, rate us on SportTracks, and talk about us everywhere!
Hollywoof
Posted: 28 Feb 10


Posts: 4,379
Location: United Kingdom
Also... just to make it easier... can you email me a sample bit of the spreadsheet :)

If you like the site: become a facebook fan, rate us on SportTracks, and talk about us everywhere!
12HonzaDe
Posted: 28 Feb 10


Posts: 5
Location: Czech Republic
I have a newest version of (dammed) MS Office, but I can do it in a older version, too... I have VBA installed, or/and I can transform data by another software, it seems to me that some text file (csv format) would be a robust way for any inport. As you pointed our MS is changing their format faster then a sprinter:)...
Cheers, 12:)
Hollywoof
Posted: 28 Feb 10


Posts: 4,379
Location: United Kingdom
Here you go - this method works OK for me - obviously you'll need to work out how to get the data into the variables from your spreadsheet.

Would love it if you could publish back your results :)

Quote:

Sub UploadFromVBA()
Dim myUserName As String
myUserName = "PUT YOUR RUNSATURDAY USER NAME HERE"
Dim myPassword As String
myPassword = "PUT YOUR PASSWORD HERE"

Dim sportType As String
sportType = "Run" ' One of "Run", "Swim", "Bike", "Walk", "Water", "Winter", "Skate", "Cross"

Dim sportSubType As String
sportSubType = "General" ' put your description here

Dim theTitle As String
theTitle = "My example run" ' title goes here

Dim longNotes As String
longNotes = "Long description" ' note that you really should XML encode this string!

Dim whenStarted As String
whenStarted = "2010-02-15T11:21:13.000Z" ' start time here

Dim durationInSeconds As Double
durationInSeconds = 3412 ' time taken in seconds here

Dim distanceInMetres As Double
distanceInMetres = 10000 ' distance in metres here

Dim calories As Long
calories = 520 ' calories here

Dim intensity As Integer
intensity = 8 ' 0 is unknown, 1->10 is easy->hard

Dim strXML As String
strXML = "<?xml version=""1.0"" encoding=""utf-8""?>"
strXML = strXML & "<soap:Envelope xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema"" xmlns:soap=""http://schemas.xmlsoap.org/soap/envelope/"">"
strXML = strXML & "<soap:Header>"
strXML = strXML & "<UploadTrackCredentials xmlns=""http://www.runsaturday.com/"">"
strXML = strXML & "<UserName>" & myUserName & "</UserName>"
strXML = strXML & "<SecretKey>" & myPassword & "</SecretKey>"
strXML = strXML & "</UploadTrackCredentials>"
strXML = strXML & "</soap:Header>"
strXML = strXML & "<soap:Body>"
strXML = strXML & "<AddSimpleActivity xmlns=""http://www.runsaturday.com/"" >"
strXML = strXML & "<type>" & sportType & "</type>"
strXML = strXML & "<subType>" & sportSubType & "</subType>"
strXML = strXML & "<title>" & theTitle & "</title>"
strXML = strXML & "<startedAt>" & whenStarted & "</startedAt>"
strXML = strXML & "<distanceInMetres>" & distanceInMetres & "</distanceInMetres>"
strXML = strXML & "<durationInSeconds>" & durationInSeconds & "</durationInSeconds>"
strXML = strXML & "<notes>" & longNotes & "</notes>"
strXML = strXML & "<calories>" & calories & "</calories>"
strXML = strXML & "<intensity>" & intensity & "</intensity>"
strXML = strXML & "</AddSimpleActivity>"
strXML = strXML & "</soap:Body>"
strXML = strXML & "</soap:Envelope>"

Dim objHTTP As New MSXML2.XMLHTTP
objHTTP.Open "post", "http://www.runsaturday.com/runsaturday/ManualSync.asmx"

objHTTP.setRequestHeader "Content-Type", "text/xml; charset=utf-8"
objHTTP.setRequestHeader "SOAPAction", "http://www.runsaturday.com/AddSimpleActivity"
objHTTP.send strXML

Dim result As String
result = objHTTP.responseText

Dim AddSimpleActivityResult As Integer
AddSimpleActivityResult = InStr(result, "<AddSimpleActivityResult>")
Dim EndAddSimpleActivityResult As Integer
EndAddSimpleActivityResult = InStr(result, "</AddSimpleActivityResult>")

If AddSimpleActivityResult = 0 Then
MsgBox "Failed"
MsgBox result
Exit Sub
End If
If EndAddSimpleActivityResult = 0 Then
MsgBox "Failed Weirdly"
MsgBox result
Exit Sub
End If

Dim lenOfTag As Integer
lenOfTag = Len("<AddSimpleActivityResult>")

Dim activityId As Long
activityId = CLng(Mid(result, AddSimpleActivityResult + lenOfTag, EndAddSimpleActivityResult - (AddSimpleActivityResult + lenOfTag)))

MsgBox "Activity added at http://www.runsaturday.com/act/" & activityId
End Sub


If you like the site: become a facebook fan, rate us on SportTracks, and talk about us everywhere!
Hollywoof
Posted: 28 Feb 10


Posts: 4,379
Location: United Kingdom
To use that method you will need to reference Microsoft XML from your VBA project.

To do this:
1. Open the VBA Macro Editor
2. Use Tools->References to add a reference from your VBA project to "Microsoft XML, v6.0" - if you don't have v6.0, then other versions will probably also work.



If you like the site: become a facebook fan, rate us on SportTracks, and talk about us everywhere!
12HonzaDe
Posted: 28 Feb 10


Posts: 5
Location: Czech Republic
Tnx, will play with it..:), now in the middle of something, but it looks feasible:)! Cheers, 12:)
Hollywoof
Posted: 28 Feb 10


Posts: 4,379
Location: United Kingdom
Repeated but slightly easier to read on http://www.runsaturday.com/About_Us/Developers

Good luck :)

If you like the site: become a facebook fan, rate us on SportTracks, and talk about us everywhere!
Users browsing this topic
Guest


Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Main Forum RSS : RSS

Clean Slate theme by Jaben Cargman (Tiny Gecko)
Yet Another Forum.net

Recent Photos

Recent PBs

Latharn 0:44:22
8.7km - BĚH ZÁMECKÝM PARKEM - Kravaře
barry 1:51:45
750m/20km/5km - Sprint - Brett Ashford Triathlon
MarvinHHGTTG 0:30:32
0.5k/5k - Bad Blau Aquathlon 2013
purkka 3:30:00
21k/42k/63k - MTB Marathon Laajavuori (Finland)
plockplock 0:25:40
5km Road - Park Run - Walsall Arboretum
Randofun 0:53:43
12k - Bandol Classic
PetrV 2:05:00
22.6k - Jezerní běh
rseidl 2:00:45
22.6k - Jezerní běh

Recent Videos