Connecting the spreadsheat to other file endings
Opened this issue · 6 comments
Could spreadsheet be assigned to other file endings as well.
I have a couple of files with endings (*.acq, *.att, *.ats, *.atr) which are in fact csv-files internally.
Renaming them to *.csv I get the spreadsheat as an entry in the context menu and I can open it successfully.
Would it be possible to assign other filetypes to be opened e.g. via some settings?
Or would that be a feature for the jupyterlab file browser in general?
jupyterlab/jupyterlab#7099 (comment)
It's fairly easy to do, but there's some ongoing work on filetype associations as you note and given the nature of vendor-specific extensions, it seems better as a user-configurable setting. I've pinged the JupyterLab maintainers, and I'll let you know what comes of that.
If you'd like, I could add this in anyway and then remove it when something lands in JupyterLab. That would get you a usable stop-gap if this is an active bottleneck for you.
I think I have seen it mentioned somewhere, that it has been implemented in jupyterlab 1.1.4. But I can't find it anymore.
Finding the following: jupyterlab/jupyterlab#6813
I was able to set the Spreadsheet as the default Viewer for csv.
But I can't use it to open acq-files for example, since it is not a valid filetype.
Yup, internally JupyterLab has two layers of indirection between files and viewers:
- Filetypes (maps an extension to a MIME type)
- DocumentRegistry (maps a MIME type to a viewer)
jupyterlab/jupyterlab#6813 lets you map additional MIME types to viewers, but it’s missing that first component (file extensions to MIME types). When I get some free time I’ll spike an extension that does that, should be pretty quick to do. That way you can specify mappings between file types and existing MIME types, like .acq
-> text/csv
. Viewer plugins like JupyterLab-Spreadsheet can pick it up from there.
Any news on how to link from extension to mimetype?
I'd actually almost gotten about halfway there by implementing support for the JupyterLab Data Registry- as long as a file could be recognized by the Data Registry it could then be opened in this extension. (The extension in turn would offer support for converting worksheets to CSVs). This made it into mainline in #17, but I had to retract it prior to the JLab 2.0 release since the Data Registry hadn't been updated yet.
Separately I had made an earlier stab at this in https://github.com/quigleyj97/jupyterlab-file-glue, but honestly I forget why I abandoned that effort- it might've been that extensions have to explicitly register the filetypes they support (cf. here), thus requiring changes to this extension as well.
I'll mull over this a bit but in the meantime you can semi-hackishly work around this with a symlink:
ln -s my-file.acq my-link.csv
That should allow JupyterLab to recognize the file as a CSV, but only works on *nix systems.