Feature request: API to create a notebook from a template

Hi, I’m working on an app that will record data in CSV files. It would be nice to have an API to put a CSV file into a new Observable notebook.

For now this will be done manually by the user: download the CSV, create a new notebook from a template, then upload the CSV as a file attachment.

That will work, but a nicer way to do it would be to create a new notebook directly from my app, using the CSV file and a notebook template. The template would have a default graph that displays the user’s data immediately, and then the user can take it from there.

(There are other integrations I could do to upload the file somewhere else, but I’m not sure it makes sense if ultimately the destination is a notebook?)

You may want to add your use case to Publicly documented read/write API. Issue #175 might also be somewhat related.

I wouldn’t get my hopes up, though. As far as I’m aware there are no plans to add a public API in the foreseeable future.

Have you considered accessing Cloud files (Google Sheets or Microsoft Excel) directly from your notebook? That way you can load the data in your cloud files and the notebook would pull from there as if it was a database (instead of having the ‘refresh’ your data by attaching a new csv file to the notebook).

Cloud files are only supported in private notebooks, though, so if you then need to share the notebook with others, you would need to create a team with those folks.

I would use a URL param to encode a URL to a CSV somewhere else on the internet.

https://observablehq.com/@tomlarkworthy/csv-viewer?source=https://cloud.storage.google.com...

So if you can control what the notebook loads just by linking to it differently.

1 Like

Thanks, but I’m thinking about the workflow a little differently. I don’t want to use a notebook as a UI to view a variety of CSV files stored elsewhere. I want the notebook to be a standalone record of a single experiment, like a page in a real notebook.

I’m imagining that each time I do an experiment, I generate some data, save it to a notebook, and do whatever’s needed to analyze and visualize the data . Then I move on. The notebook then serves as a record of an old experiment, including both some ad-hoc code and data. If I come up with reusable code then I’ll copy it to a library, or another notebook for that purpose.

There are workarounds where you store data in one place and the code in another, but that’s a way for the code and data to get separated. So I think I’ll just stick to manually attaching the CSV file for now.

2 Likes