diff options
| author | Claude Paroz <claude@2xlibre.net> | 2020-02-12 20:12:53 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-02-12 21:12:53 +0200 |
| commit | aaeb5c83600052f6696eb09a155112bc0252fffa (patch) | |
| tree | 8af2cc62f8966ec79f6300c9a27d1e017a09d4cc /tests/test_tablib.py | |
| parent | 7a6c623cca51293d82bfc1f09bb1aa123708f2da (diff) | |
| download | tablib-aaeb5c83600052f6696eb09a155112bc0252fffa.tar.gz | |
Fixes #226 - Allow importing ragged CSV files (#456)
Diffstat (limited to 'tests/test_tablib.py')
| -rwxr-xr-x | tests/test_tablib.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/test_tablib.py b/tests/test_tablib.py index b20b669..3acdd44 100755 --- a/tests/test_tablib.py +++ b/tests/test_tablib.py @@ -804,6 +804,25 @@ class CSVTests(BaseTestCase): data.csv = csv_text self.assertEqual(data.width, 7) + def test_csv_import_set_ragged(self): + """Import CSV set when not all rows have the same length.""" + csv_text = ( + "H1,H2,H3\n" + "A,B\n" + "C,D,E\n" + "\n" + "F\n" + ) + dataset = tablib.import_set(csv_text, format="csv") + self.assertEqual( + str(dataset), + 'H1|H2|H3\n' + '--|--|--\n' + 'A |B | \n' + 'C |D |E \n' + 'F | | ' + ) + def test_csv_export(self): """Verify exporting dataset object as CSV.""" |
