Generate classes from CSV

Updated: Jul 8, 2018

Generate C# model or stub classes from CSV file. You can select the property naming convention (Pascal, Camel or Original) and whether or not to generate a class map for the CsvHelper library. The generator is smart enough to detect data types for the output properties of the C# class. It can even work with just the header row of a CSV file.

Input: Paste CSV content below



Settings




Output: Generated Classes


CSV is an old & very popular format for storing tabular data. It has been used in the desktop as well as mainframe. It is a simple & compact format that works really well for tabular data and so is still in use today.
First Row Is Header
If selected, first row is assumed to be the header and property names are generated using it otherwise property names are generated automatically using a number pattern: column 1, column 2, column 3, etc. In the latter case, first row is interpreted as data.
First Row is Header On
[
  {
    "name": "Robin Hood",
    "department": "Sales",
    "salary": 200
  }
]
First Row is Header Off
[
  {
    "column 1": "Name",
    "column 2": "Department",
    "column 3": "Salary"
  },
  {
    "column 1": "Robin Hood",
    "column 2": "Sales",
    "column 3": 200
  }
]
Delimiter
The delimiter in the input CSV is specified here. In most cases the default setting Auto Detect works fine. But, in really small CSV data with delimiters also occurring as literals, the auto detection logic might not choose the correct delimiter. In such a scenario, the delimiter can be manually specified. Following are the choices for delimiters:-
  • Comma
  • Tab
  • Space
  • Pipe
  • Semi-Colon
Class Name
The name of the genreated Class.
Language
The language for which you want the classes to be generated. Currently C# is the only option available. But, we intend to extend it to Java in the near future.
Generate Class Map
If selected, a CsvHelper compliant class map is generated.
Generate Class Map On
public class Person
{
    public string FullName { get; set; }
    public int age { get; set; }
}

public class PersonClassMap : ClassMap
{
    public PersonClassMap()
    {
        Map(m => m.FullName).Name("Full Name");
        Map(m => m.age).Name("age");
    }
}
Generate Class Map Off
public class Person
{
    public string FullName { get; set; }
    public int age { get; set; }
}
Property Naming Strategy
Choose the naming strategy of the generated properties. The available options are:-
Cleanse Only
public class Person
{
    public string FullName { get; set; }

    public int age { get; set; }
}
Pascal Case
public class Person
{
    public string FullName { get; set; }

    public int Age { get; set; }
Camel Case
public class Person
{
    public string fullName { get; set; }

    public int age { get; set; }
}
 
Created: Dec 9, 2017
Online Tool Designed For: Windows, OS X, Android, iOS, Linux