diff --git a/csv_diff/__init__.py b/csv_diff/__init__.py index 7c018d0..08ee893 100644 --- a/csv_diff/__init__.py +++ b/csv_diff/__init__.py @@ -10,7 +10,7 @@ def load_csv(fp, key=None, dialect=None): peek = fp.read(1024 ** 2) fp.seek(0) try: - dialect = csv.Sniffer().sniff(peek, delimiters=",\t") + dialect = csv.Sniffer().sniff(peek, delimiters=",\t;") except csv.Error: # Oh well, we tried. Fallback to the default. pass diff --git a/tests/test_cli.py b/tests/test_cli.py index bdaa47c..af94165 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -153,3 +153,36 @@ def test_column_containing_dot(tmpdir): "columns_added": [], "columns_removed": [], } == json.loads(result.output.strip()) + + +def test_semicolon_delimited(tmpdir): + # https://github.com/simonw/csv-diff/issues/6 + one = tmpdir / "one.csv" + two = tmpdir / "two.csv" + one.write( + dedent( + """ + id;name + 1;Mark + """ + ).strip() + ) + two.write( + dedent( + """ + id;name + 1;Brian + """ + ).strip() + ) + result = CliRunner().invoke( + cli.cli, [str(one), str(two), "--key", "id", "--json"], catch_exceptions=False + ) + assert 0 == result.exit_code + assert { + "added": [], + "removed": [], + "changed": [{"key": "1", "changes": {"name": ["Mark", "Brian"]}}], + "columns_added": [], + "columns_removed": [], + } == json.loads(result.output.strip())