Created
August 2, 2015 17:36
-
-
Save xurizaemon/24446b9d758f2c0039e7 to your computer and use it in GitHub Desktop.
RescueTime Data Export
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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() |
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
Hey, how do I install or use this?