open-contracting-archive / toucan

A web interface to OCDS Kit and Flatten Tool
https://toucan.open-contracting.org
BSD 3-Clause "New" or "Revised" License
2 stars 5 forks source link

to-json: InvalidFileException if user uploads a single CSV #72

Closed jpmckinney closed 4 years ago

jpmckinney commented 4 years ago

InvalidFileException: openpyxl does not support .csv file format, please check you can open it with Excel first. Supported formats are: .xlsx,.xlsm,.xltx,.xltm

https://sentry.io/organizations/open-data-services/issues/1501778683/?project=1798699&query=is%3Aunresolved

Copying some content from Sentry:

variable value
config {app_base_template: 'cove_ocds/base.html', app_name: 'cove_ocds', app_strapline: 'Validate and Explore your data.', app_verbose_name: 'Open Contracting Data Standard Validator', root_list_path: 'releases', schema_codelists: {1.1: 'https://raw.githubusercontent.com/open-contracting/standard/1.1/standard/schema/codelists/'}, schema_host: None, schema_item_name: 'release-schema.json', schema_name: {record: 'record-package-schema.json', release: 'release-package-schema.json'}, schema_version_choices: {1.0: ['1.0', 'https://standard.open-contracting.org/schema/1__0__3/'], 1.1: ['1.1', 'https://standard.open-contracting.org/schema/1__1__4/']}}
extension '.csv'
input_file 2020-02-07/subasta-42a9b0b1-bf80-4cd7-8f76-89e8e5293e96.csv
input_file_path 'media/2020-02-07/subasta-42a9b0b1-bf80-4cd7-8f76-89e8e5293e96.csv'
input_format 'xlsx'
output_dir 2020-02-07/unflatten-42a9b0b1-bf80-4cd7-8f76-89e8e5293e96
output_name 'media/2020-02-07/unflatten-42a9b0b1-bf80-4cd7-8f76-89e8e5293e96.json'
request <WSGIRequest: GET '/to-json/go/'>
aguilerapy commented 4 years ago

For to-json, CSV files must be compressed at the root of a ZIP file, for a single CSV file too. ¿Do you want to receive CSV without being in zip format? @jpmckinney

jpmckinney commented 4 years ago

Let's support uploading a single CSV. I'm not sure how the user managed to submit a single CSV (since there's client-side validation to require ZIP and XLSX), but it caused an error to be reported to Sentry.