liveBook · Manning

CSV

As explained in .NET in Action, Second Edition

CSV is a delimited text format in which records are represented as lines and fields are separated by commas, with quoting and escaping rules for special content.

CSV represents records as lines with comma-separated fields. A practical importer reads the input stream line by line, parses each line into customer data, and ignores lines that do not contain exactly three values: email, customer name, and license. section 7.4.1

Customer batch import

A C# CsvImporter receives a Stream and repository dependency, reads each line asynchronously, and checks the parsed email against the repository. It creates a customer when none exists; otherwise, it updates the existing customer’s name and license. section 7.4.1

Listing 7.18 Customer class
public class Customer                 #1
{
  public int Id { get; set; }         #2
  public string Email { get; set; }
  public string Name { get; set; }
  public string License { get; set; }
}

Browse the focused C# implementation that reads CSV lines, skips malformed records, and selects repository create or update operations. section 7.4.1

How .NET in Action, Second Edition covers it

How deep it goes
Explains line reading, three-field validation, parsing, and persistence branching, but does not detail general CSV quoting rules.
Examples
Uses customer records containing email, name, and license fields, including duplicate-email updates and malformed-line skips.
What it assumes
Assumes familiarity with C# classes, streams, asynchronous methods, and repository interfaces.
What you can do after
Build it from scratch as a C# importer that converts CSV lines into repository create and update operations.
How it connects
Connects CSV with streams, repositories, asynchronous processing, and unit testing.

Also explained in

Compare how 15 books explain CSV →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of .NET in Action, Second Edition. The section links point to the parts of the book it draws on.