Skip to content

Detect CSV delimiter when one is not supplied (fixes #622) - #699

Open
emmanuelkwakuotoo247-a11y wants to merge 1 commit into
jazzband:masterfrom
emmanuelkwakuotoo247-a11y:fix-csv-delimiter-detection
Open

emmanuelkwakuotoo247-a11y wants to merge 1 commit into
jazzband:masterfrom
emmanuelkwakuotoo247-a11y:fix-csv-delimiter-detection

Conversation

@emmanuelkwakuotoo247-a11y

Copy link
Copy Markdown

Description

Fixes #622.

CSVFormat.import_set() sets the delimiter with kwargs.setdefault('delimiter', cls.DEFAULT_DELIMITER), which always resolves to a comma. The standard library's
csv.Sniffer — already used by detect() in the same file — is therefore never given
the stream to inspect, so a CSV that uses any other delimiter is parsed as a single
column:

>>> import tablib
>>> data = tablib.Dataset()
>>> data.csv = "test:test2\nvalue1:value2\n"
>>> data.headers
['test:test2']
>>> data[0]
('value1:value2',)

@emmanuelkwakuotoo247-a11y

Copy link
Copy Markdown
Author

Co-authored-by: Eugene Dela Abdemade <@eugenedela44-cloud> https://github.com/eugenedela44-cloud
Co-authored-by: Abigail Aseda Owusuaa <@Abby67-ship-it> @Abby67-ship-it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Simple csv file can't be parsed correctly because of Sniffer() parameters

1 participant