Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/willsoss/csv
Lightweight yet complete CSV reader and writer.
https://github.com/willsoss/csv
Last synced: 21 days ago
JSON representation
Lightweight yet complete CSV reader and writer.
- Host: GitHub
- URL: https://github.com/willsoss/csv
- Owner: WillSoss
- License: mit
- Created: 2023-08-16T00:29:54.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-12-19T19:53:39.000Z (about 1 year ago)
- Last Synced: 2024-12-01T11:44:11.117Z (about 1 month ago)
- Language: C#
- Size: 12.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# WillSoss.Csv
A lightweight, efficient, and complete implementation that will correctly deal with escaped qualifiers and line breaks in fields.## Reading Files
```
using var reader = new CsvReader("c:\my-data.csv");string[] record = null;
while ((record = reader.Read()) != null)
{
Console.WriteLine($"First field: {record[0]}");
Console.WriteLine($"Second field: {record[1]}");
}
```### Qualifiers and Delimiters
`CsvReader` can read files with non-standard qualifiers (usually quotes: "This is qualified") and delimiters (usually commas: 1,2,3) by specifying the character used for each in the constructor:```
// Reads a file with data like: ~field 1~;~field 2~
new CsvReader(filename, '~', ';');
```
## Writing Files```
using var writer = new CsvWriter("c:\my-data.csv");writer.Write(new string[] { "first", "second", "third" });
await writer.WriteAsync(new int[] { 1, 2, 3 });
```