BurntSushi / BurntSushi/rust-csv
Support multi-character delimiters
- Dominant language
- Rust
- Stars
- 2k
- Forks
- 257
- PR merge metrics
- No merged PRs in 30d
Description
#### What version of the `csv` crate are you using?
1.1.3
#### Briefly describe the question, bug or feature request.
This was briefly discussed in #47, but I'd like to see support for delimiters of multiple characters. For use cases where CSV files may contain arbitrary strings, a single character delimiter is often not enough. In that case, having the ability to specify multiple delimiters is very useful.
This feature is not supported by csv in Python, but it is supported in Pandas (see https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.read_csv.html).
#### Include a complete program demonstrating a problem.
Example with `git log`:
```bash
$ git log --pretty=format:"%h|%s|%aN|%aE|%aD" -n 10 > test.csv
$ cat test.csv
331e56ec2|This is a redacted message.|Redacted Name|redacted@email.com|Wed, 7 Oct 2020 09:00:51 -0700
280c2120e|This is a redacted message.|Redacted Name|redacted@email.com|Tue, 6 Oct 2020 16:48:09 -0700
c0e58d9d6|This is a redacted message.|Redacted Name|redacted@email.com|Tue, 6 Oct 2020 16:42:50 -0700
```
```python
>>> import pandas as pd
>>> pd.read_csv('test.csv', sep='\|')
331e56ec2 This is a redacted message. Redacted Name redacted@email.com Wed, 7 Oct 2020 09:00:51 -0700
0 280c2120e This is a redacted message. Redacted Name redacted@email.com Tue, 6 Oct 2020 16:48:09 -0700
1 c0e58d9d6 This is a redacted message. Redacted Name redacted@email.com Tue, 6 Oct 2020 16:42:50 -0700
```
Random example
```bash
$ cat test2.csv
a|||g
b|||h
c|||i
d|||j
e|||k
f|||l
```
```python
>>> import pandas as pd
>>> pd.read_csv('test2.csv', sep='\|\|\|')
a g
0 b h
1 c i
2 d j
3 e k
4 f l
```
Let me know if this sounds reasonable! If so, I'd be happy to help implement this.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.