Add TSV file support to CsvConverter#2027
Conversation
|
@microsoft-github-policy-service agree |
trippinganymess
left a comment
There was a problem hiding this comment.
the delimiter should explicitly check both the extension and the MIME type before being intialized.
|
|
||
| # Parse CSV content | ||
| reader = csv.reader(io.StringIO(content)) | ||
| delimiter = "\t" if (stream_info.extension or "").lower() == ".tsv" else "," |
There was a problem hiding this comment.
the accept() function, uses the MIME type and the extension of a file to determine it's type. so In a scenario where a file arrives from a cloud service with no extension, but MIME type would be accepted. but You are currently setting the delimiter by only checking the extension type and not the MIME type. This will cause the function to crash in case a file without an extension is accepted and will automatically default to "," every time.
Example scenario :
- file received from cloud ( without extension but with MIME type "tab-seperated-values")
- the accept function allows this file and returns True.
delimiter = "\t" if (stream_info.extension or "").lower() == ".tsv" else ","doesn't account for the MIME type and defaults to "," which crashes the whole program.
There was a problem hiding this comment.
This also has been addressed in #2021
There was a problem hiding this comment.
Thanks for the review! Good catch. I'll update the delimiter detection to consider both the file extension and MIME type.
Summary
Adds support for TSV (Tab-Separated Values) files in CsvConverter.
Changes
.tsvto accepted file extensionstext/tab-separated-valuesMIME type support\t)Fixes #2022