Reputation: 1033
Is there a way to check the time I've spent developing a Jupyter Notebook?
I guess something like the time since the .ipynb was created (as it is constantly saved) to until the last save?
There are applications that show the amount of time that a file has been edited, so something similar to that.
Upvotes: 1
Views: 1474
Reputation: 1033
Thanks @cardamom that pointed me in the right direction. I added this to a cell to get the name of the notebook into nb_name
%%javascript
IPython.notebook.kernel.execute('nb_name = "' + IPython.notebook.notebook_name + '"')
Then this into another cell, and it seems to give me the answer...just a little formatting needed.
# Get the path from
path = !echo %cd%
# Combine the path and filename
completepath = path[0] + '\\' + nb_name
filecreationtime = os.path.getatime(completepath)
filecreationtime = datetime.utcfromtimestamp(filecreationtime)
now = datetime.now()
print(f'Notebook: {nb_name}')
print(f'At path: {path[0]}')
print(f'Dev Time: {str(now - filecreationtime)}')
The thing is, it doesn't seem completly correct as one hour is added. I'm using windows, so I guess it must be down to the os.path.getctime.
Upvotes: 1
Reputation: 7421
If you put the following in a cell it will probably do that on a windows system:
import sys
import os
from datetime import datetime
completepath = sys.argv[0]
filecreationtime = os.path.getmtime(completepath)
filecreationtime = datetime.utcfromtimestamp(filecreationtime)
now = datetime.now()
str(now - filecreationtime)
I am using a Linux system and it seems that creation date is not really accessible as described here
Maybe there is a variable that can be somehow written into the .ipynb file at creation to get around this.
Upvotes: 1