How to include observablehq/stdlib in a local project and not use npm

I want to directly use the script tag like this to use FileAttachment in local project.

<script src="https://unpkg.com/@observablehq/stdlib@3"></script>

Does this make sense, and if so, can I convert the file data into variables, out of the scope constraints of the file request?

var t;
d3.csv('test.csv', function(data) {t = data;})
console.log(t); // undefine

My ideal usage would be something like this.

var data = d3.csvParse(await FileAttachment("myFile.csv").text())
console.log(data);

Hi @HazardTrigger, FileAttachment if a server feature on Observable, I guess if you want to access local files using Observable stlib you can look at this way to do it

essentially you would craft your notebook code on Observable, export the code, run it locally and then load your data using the UI. As you might know accessing the file system is not something allowed through browsers, and you can read more about this here

@radames Thank you very much for your answer, this question has really been bothering me for a long time! :joy:

1 Like