Skip to content

Commit

Permalink
update readme examples.
Browse files Browse the repository at this point in the history
  • Loading branch information
Sov3rain committed Oct 6, 2024
1 parent d56eb22 commit f27ce7e
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ You can parse a string using:
```c#
CsvParser.ParseFromString(
string data,
bool header = true,
bool hasHeader,
    bool removeHeader = true,
Delimiter delimiter = Delimiter.Auto)
```

Expand All @@ -42,8 +43,9 @@ or a file using:
```c#
CsvParser.ParseFromPath(
string path,
Delimiter delimiter = Delimiter.Auto,
bool header = true,
    bool hasHeader,
    bool removeHeader = true,
    Delimiter delimiter = Delimiter.Auto,
Encoding encoding = null)
```

Expand All @@ -56,12 +58,14 @@ You can map your CSV to a concrete type using generic methods, which will return
```c#
CsvParser.ParseFromString<T>(
string data,
    bool hasHeader,
    Delimiter delimiter = Delimiter.Auto)
```

```c#
CsvParser.ParseFromPath<T>(
string path,
    bool hasHeader,
    Delimiter delimiter = Delimiter.Auto,
    Encoding = null)
```
Expand All @@ -73,7 +77,7 @@ CsvParser.ParseFromPath<T>(
Getting back a `List<LIst<string>>`:

```c#
var sheet = CsvParser.ParseFromString(csvString);
var sheet = CsvParser.ParseFromString(csvString, hasHeader: true);

foreach (var row in sheet)
{
Expand All @@ -90,7 +94,7 @@ class User
    public string Email { get; set; }
}

var users = CsvParser.ParseFromString<User>(csvString);
var users = CsvParser.ParseFromString<User>(csvString, hasHeader: true);

foreach (User user in users)
{
Expand All @@ -110,7 +114,7 @@ class User
    public string Email { get; set; }
}

var users = CsvParser.ParseFromString<User>(csvString);
var users = CsvParser.ParseFromString<User>(csvString, hasHeader: true);
```

Both attributes can be mixed in a class, but **name-based mapping will be prioritized**.
Expand Down

0 comments on commit f27ce7e

Please sign in to comment.