mirror of
https://github.com/sharkdp/bat.git
synced 2025-08-18 20:10:13 +02:00
Correctly handle CSV files with a single separator throughout
better auto-detection of CSV delimiter - files with a tsv extension are automatically detected as tab delimited - other files parsed as CSV go through the following steps: - if the first line contains at least 3 of the same separator, it uses that separator as a delimiter - if the first line contains only one supported separator character, it uses that separator as a delimiter - otherwise it falls back to treating all supported delimiters as the delimiter supported delimiters, in precedence order: - comma `,` - semi-colon `;` - tab `\t` - pipe `|`
This commit is contained in:
3
tests/syntax-tests/source/CSV/comma-delimited.csv
vendored
Normal file
3
tests/syntax-tests/source/CSV/comma-delimited.csv
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
foo,bar,baz,this|that,test,colors,cycle
|
||||
1.2,1.7,2.5,blah;cool,test,colors,cycle
|
||||
|
|
3
tests/syntax-tests/source/CSV/decimals_comma_decimal_point_pipe_delimited.csv
vendored
Normal file
3
tests/syntax-tests/source/CSV/decimals_comma_decimal_point_pipe_delimited.csv
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
foo|bar|baz
|
||||
1,2|1,7|2,7
|
||||
1,5|8,5|-5,5
|
|
3
tests/syntax-tests/source/CSV/decimals_comma_decimal_point_semicolon_delimited.csv
vendored
Normal file
3
tests/syntax-tests/source/CSV/decimals_comma_decimal_point_semicolon_delimited.csv
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
foo;bar;baz
|
||||
1,2;1,7;2,7
|
||||
1,5;8,5;-5,5
|
|
3
tests/syntax-tests/source/CSV/simple.tsv
vendored
Normal file
3
tests/syntax-tests/source/CSV/simple.tsv
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
foo bar baz|;, test hello world tsv
|
||||
1,2 1,7 2,7 a b c "hello again" tsv
|
||||
";|," ;|, baz test "hello world" tsv
|
|
Reference in New Issue
Block a user