Published
Edited
Jul 21, 2022
1 star
Insert cell
# FileAttachment with dynamic filenames
Insert cell
/**
* Returns a FileAttachment from a dynamic filename.
*
* @param {string} filename String containing the name of the attached file.
* @returns {FileAttachment} A FileAttachment object.
* @example
* ```
* const file = "example.csv";
* FileAttachmentDynamic(file).csv()
* ```
*/
function FileAttachmentDynamic(filename) {
return new Function("FileAttachment", `return FileAttachment("${filename}")`)(FileAttachment)
}
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more