Skip to content

Commit aecbec9

Browse files
Update README with new type converters and LumenWorks APIs
Added documentation for new built-in type converters (`money`, `vector` for SQL Server 2025). Introduced a section on LumenWorks compatibility, describing new methods for easier migration. Documented handling of empty or whitespace-only headers and how to customize default header names.
1 parent 644c078 commit aecbec9

File tree

1 file changed

+47
-1
lines changed

1 file changed

+47
-1
lines changed

project/Dataplat.Dbatools.Csv/README.md

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ while (reader.Read())
360360
}
361361
```
362362

363-
**Built-in type converters:** `Guid`, `bool`, `DateTime`, `short`, `int`, `long`, `float`, `double`, `decimal`, `byte`, `string`
363+
**Built-in type converters:** `Guid`, `bool`, `DateTime`, `short`, `int`, `long`, `float`, `double`, `decimal`, `byte`, `string`, `money`, `vector` (SQL Server 2025)
364364

365365
**Combine with schema inference:**
366366

@@ -458,6 +458,52 @@ reader.GetString(2); // ""
458458
| `,"",` (quoted empty) | `""` (empty string) | `""` (empty string) |
459459
| `,value,` | `"value"` | `"value"` |
460460

461+
### LumenWorks Compatibility
462+
463+
For projects migrating from LumenWorks CsvReader, these methods provide familiar APIs:
464+
465+
```csharp
466+
using var reader = new CsvDataReader("data.csv");
467+
468+
while (reader.Read())
469+
{
470+
// Get column index by name (-1 if not found, unlike GetOrdinal which throws)
471+
int idx = reader.GetFieldIndex("ColumnName");
472+
473+
// Get current record as reconstructed CSV string (useful for error logging)
474+
string rawData = reader.GetCurrentRawData();
475+
476+
// Efficiently copy all fields to an array
477+
string[] values = new string[reader.FieldCount];
478+
reader.CopyCurrentRecordTo(values);
479+
480+
// Check if current record had issues
481+
if (reader.MissingFieldFlag)
482+
Console.WriteLine("Record had missing fields (padded with nulls)");
483+
if (reader.ParseErrorFlag)
484+
Console.WriteLine("Record had a parse error that was skipped");
485+
}
486+
487+
// Check if stream is fully consumed
488+
if (reader.EndOfStream)
489+
Console.WriteLine("Finished reading all data");
490+
```
491+
492+
### Empty Header Handling
493+
494+
CSV files with empty or whitespace-only headers are automatically assigned default names:
495+
496+
```csharp
497+
// CSV: Name,,Value
498+
// Headers become: Name, Column1, Value
499+
500+
var options = new CsvReaderOptions
501+
{
502+
DefaultHeaderName = "Field" // Custom prefix (default is "Column")
503+
};
504+
// Headers become: Name, Field1, Value
505+
```
506+
461507
## Configuration Options
462508

463509
### CsvReaderOptions

0 commit comments

Comments
 (0)