nietras / Sep

World's Fastest .NET CSV Parser. Modern, minimal, fast, zero allocation, reading and writing of separated values (`csv`, `tsv` etc.). Cross-platform, trimmable and AOT/NativeAOT compatible.
http://nietras.com
MIT License
840 stars 33 forks source link

Is it possible to supply multiple separators? #156

Closed A9G-Data-Droid closed 3 weeks ago

A9G-Data-Droid commented 1 month ago

Is it possible to supply multiple separators, like Split) does?

Parameters

separator Char[]

An array of characters that delimit the substrings in this string

DaghanGuven commented 1 month ago

If i understand your question correctly, yes it is.

string example = "one,two.three;four";
char[] separators = { ',', '.', ';' };
string[] result = example.Split(separators);

// result = ["one", "two", "three", "four"]
A9G-Data-Droid commented 1 month ago

@DaghanGuven That is what I am doing currently, that's what my link is to.

I'm asking if Sep can do this. There is an interface on ReadOnlySpan<char> called SplitAny that could be used.

However, the Sep Object only appears to store a single char, with no overload for char[]

nietras commented 3 weeks ago

@A9G-Data-Droid thanks for trying out Sep and asking this question. Multiple separators is not supported no. Sep uses highly optimized code for parsing and having to support multiple separators would be a lot of work. Hence, I have no immediate plans to support this in Sep. If you only need basic parsing as supported by dotnet I would just use that. :)

A9G-Data-Droid commented 3 weeks ago

Thanks @nietras ! Sep is great and it has become the tool I reach for whenever I am handling delimited data sets. In this case I will continue to use my own solution involving ReadOnlySpan<char>.SplitAny

nietras commented 2 weeks ago

@A9G-Data-Droid thanks 🤗