observablehq / feedback

Customer submitted bugs and feature requests
42 stars 3 forks source link

"Insert into Notebook" fails with a csv. #526

Open gallowayevan opened 1 year ago

gallowayevan commented 1 year ago

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):

CobusT commented 1 year ago

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

gallowayevan commented 1 year ago

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

mootari commented 1 year ago

@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.

gallowayevan commented 1 year ago

Yes - a reload does the trick.