Skip to content

Instantly share code, notes, and snippets.

@xurizaemon
Created August 2, 2015 17:36
Show Gist options
  • Star 12 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save xurizaemon/24446b9d758f2c0039e7 to your computer and use it in GitHub Desktop.
Save xurizaemon/24446b9d758f2c0039e7 to your computer and use it in GitHub Desktop.
RescueTime Data Export
#!/usr/bin/env python
#-*- coding: utf-8 -*-
# RescueTime Data Exporter
# Dan Nixon
# 18/09/2011
import urllib
apiKey = "API_KEY"
fileDirectory = ""
filePrefix = "RescueTimeData"
def main():
print "RescueTime Data Exporter"
print "Dates in format YYYY-MM-DD"
date_s = raw_input("Start Date: ")
date_e = raw_input("End Date: ")
print "Getting Data for Interval", date_s, "to", date_e
params = urllib.urlencode({'key':apiKey, 'perspective':'interval', 'format':'csv', 'restrict_begin':date_s, 'restrict_end':date_e})
u = urllib.urlopen("https://www.rescuetime.com/anapi/data", params)
CSVdata = u.read()
filePath = fileDirectory + filePrefix + date_s.replace("-", "") + "-" + date_e.replace("-", "") + ".csv"
f = open(filePath, "w")
f.write(CSVdata)
f.close()
print "Data Saved to", filePath
print ""
main()
@JaimeObregon
Copy link

Worked for me as of today. Thank you.

@willgriffiths
Copy link

Still working. Thanks. 👍

@DominikAgejev
Copy link

Hey, how do I install or use this?

@veekas
Copy link

veekas commented Jun 28, 2017

Hi, thanks for this! It seems to work but only exports a blank csv. Any idea how to fix this?

EDIT: Export only works in 6-month intervals. Modified to append each 6-month interval to the original csv. Thanks again!

filePath = fileDirectory + filePrefix + ".csv"
f = open(filePath, "a")

EDIT2: @GloryousMC I forked this and added some comments to help you run this code. Let me know if you have any questions about it: https://gist.github.com/veekas/2fe3cf30fe6375f5d121c6372a550000

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment