[IPython-User] add new metadata in the current notebook
Sat Feb 23 04:18:42 CST 2013
Le 23 févr. 2013 à 03:03, epi a écrit :
> i was looking for a way to add new "hidden metadata" such as "author" , "date", "description" .. others in the "current notebook" (e.g. during a notebook session)
Yes, this is something we want to add. We will first finish moving to bootstrap before writing the UI for that.
Al also planned on adding "license" and stuff like that and make it available in nbconvert/viewer.
ANd it is one of the things that are annoying me right now and that I would like to have.
The "author" will more probably be "authors" and be a list of dict with fields like
name, email, github_handle, adress... etc we have to think carefully of the structure.
Metadata would also store things like the main language of the notebook (it won't by only python forever !)
An IPEP would be welcomed with proposal of data structure.
> def addNbTag(key, val):
> # add the new tag in the current notebook
> # and save it
> # nbdir = check the notebook.dir
> # nbname = check the current notebook name
> # nb = nbdir/nbname
> # nb[u'metadata'][u'key'] = 'val'
> # save the notebook embedding the new metadata
I would suggest looking at
That provide a "raw edit" button for metadata on the per-cell basis.
That would require writing Json by hand for now.
Also, if you go this way now I would suggest you put the metadata in a sub key to avoid future conflict.
> in order to be able to do in python :
> from IPython.nbformat import current
> f = open('file.ipynb','r')
> s = f.read()
> nb = current.reads(s, u'json')
Yes, this would be the right way to do it, maybe with get() to avoid non existing keys...
> Have you any suggestion ?
> IPython-User mailing list
More information about the IPython-User