Converter

CSV Configuration

Three settings control how CSV, TAB, and PIPE-delimited input is parsed: whether the first row is column headers, whether fields are enclosed in quotes, and whether to skip the first row entirely.

Three settings control how CSV, TAB, and PIPE-delimited input is parsed: whether the first row is column headers, whether fields are enclosed in quotes, and whether to skip the first row entirely.

WithFirstLineHasColumnNames tells the converter to treat row 1 as column headers - these become property names when converting to a class or column headers in a grid. WithFieldsEnclosedInQuotes enables quoted-field parsing for fields wrapped in double quotes, including those that contain delimiters. WithIgnoreFirstLineColumnNames reads but discards the first row - useful when a header row exists in the file but you do not want it treated as data or carried through as headers.

TIP

WithFirstLineHasColumnNames(true) uses the first row as named columns. WithIgnoreFirstLineColumnNames(true) skips the first row entirely without using it as headers. Use one or the other, not both.

Examples

GPAL Fluent: High-level fluent C# API

//These three settings apply to any delimited format - CSV, TAB, and PIPE. They have no effect when the input format is JSON, XML, YAML, or other self-describing formats.

// Standard CSV with quoted fields and headers string json; GPAL.Converter .WithInput(GPAL.FileFor("contacts.csv")) .WithFirstLineHasColumnNames(true) .WithFieldsEnclosedInQuotes(true) .WithOutputType(DataFormat.JSON) .SaveTo(ref json); // CSV export where the header row should be skipped var grid = GPAL.Grid.ToGPALObject(); GPAL.Converter .WithInput(GPAL.FileFor("export.csv")) .WithIgnoreFirstLineColumnNames(true) .SaveTo(ref grid);