feedback icon indicating copy to clipboard operation
feedback copied to clipboard

"Insert into Notebook" fails with a csv.

Open gallowayevan opened this issue 3 years ago • 4 comments

When I attach a csv to a notebook and click "Insert into Notebook" I get this error: Error: unsupported file type: application/vnd.ms-excel. If I then use, "Copy Usage Code" with the same file, it works fine.

To Reproduce

  1. Attach file.
  2. Click "Insert into Notebook"
  3. See error.

Expected behavior The same behavior as "Copy Usage Code" without the copy and paste step.

Screenshots Screenshot 2023-01-13 at 13-52-14 Examining PCC Index 2017-2021 _ Sheps Health Workforce Observable

Desktop (please complete the following information):

  • OS: Windows 10
  • Browser: Firefox
  • Version 108.0.2

gallowayevan avatar Jan 13 '23 18:01 gallowayevan

Could you please share the csv file? Or a redacted one?

CobusT avatar Jan 13 '23 19:01 CobusT

Here is a notebook with a csv that had this issue: https://observablehq.com/d/513a07515763686a For reasons I don't understand, the file loaded as a database cell successfully (the error went away) as soon as I published the notebook to Public(unlisted). This still seems odd, and I think you will see the error if you download the csv and reattach to a clean notebook.

In any case, it is also an unexpected behavior, even if it worked correctly. It diverges from the behavior of "Copy usage code" and it's not clear to why a database cell would be the default here. Thanks for looking into this.

Best, Evan

gallowayevan avatar Jan 17 '23 19:01 gallowayevan

@gallowayevan Can you confirm that the error disappears if you simply reload the notebook?

I suspect that what happens here is:

  1. when you upload the file, the MIME type gets reported by the browser
  2. on your system .csv extensions are registered as Excel files, resulting in this specific MIME type
  3. When you publish or reload the notebook, the file is fetched again with the MIME type now dictated by the Observable server

Edit: A quick way to test this is two create two cells:

viewof file = html`<input type="file">`
file.type

and then select a file.

mootari avatar Jan 17 '23 19:01 mootari

Yes - a reload does the trick.

gallowayevan avatar Jan 17 '23 20:01 gallowayevan