Ezfx.Csv 2.4.8

Auto Generate CSV Object Class. To add CSV Object Classes based on the CSV file you provided, Please Also install the VSIX(Visual Studio Extension) also named CSV2Entity or Ezfx.Csv. https://github.com/juwikuang/csv2entity/releases

Install-Package Ezfx.Csv -Version 2.4.8
dotnet add package Ezfx.Csv --version 2.4.8
<PackageReference Include="Ezfx.Csv" Version="2.4.8" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Ezfx.Csv --version 2.4.8
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

CSV2Entity

Build status
Build Status

This Software REFUSE 996 Chinese Companies

996 ICU Save Chinese Developers

Install

Install Core from Nuget

Instial Visual Studio Extension from marketplace

https://marketplace.visualstudio.com/items?itemName=EricZhou.int123

To view the introduce Video please visit:

https://youtu.be/z3eB05DaQuI

What is CSV

CSV is the abbreviation of Comma-separated values, a file format stores tabular data in plain-text form, usually with .csv extension. CSV is a simple file format that is widely supported by consumer, business, and scientific applications.

Examples

Example of a USA/UK CSV file

Year,Make,Model,Length

1997,Ford,E350,2.34

2000,Mercury,Cougar,2.38

CSV Entity

In order to build CSV entities, we need something more. Csharp’s Attribute Mechanism provides us what we need by decorate CSV class properties with a custom attribute. Custom attribute defines CVS field’s display name and order. Here is the CsvFieldAttribute:

public class CsvFieldAttribute:Attribute

{

   public string Name { get; set; }

   public int Order { get; set; }

}

With CsvFieldAttribute, now we can decorate our own class.

[CsvObject(CodePage = 936, Description = "", HasHeader = true, Name = "")]
public class Car

{

   [SystemCsvColumn(Name = "Year", Order = 0)]

   public string Year { get; set; }

   [SystemCsvColumn(Name = "Make", Order = 1)]

   public string Make { get; set; }

   [SystemCsvColumn(Name = "Model", Order = 2)]

   public string Model { get; set; }

   [SystemCsvColumn(Name = "Length", Order = 3)]

   public string Length { get; set; }

}

Generate CSV Class

So, do we need to create CSV classes manually? Of cause not. So I developed the following tool to generate CSV classes:

To Generate CSV Classes, you have to install the VSIX file:

VSIX file

After the installation a new template called EZFX CSV Class will be displayed in your Visual Studio 2010 both in language VB and C#.

Add VB Class:

CS

Add C# Class:

CS

After click of add, a CSV Generation Wizard Window will be displayed, you can select a CSV file by click the browse button, this Wizard support Excel(xls, xlsx) and Access files(mdb, accdb), too. You specify the encoding for the CSV file and table name for Excel and Access file.

CSV Generation Wizard

The following is the generated file:

The C# code:

using Ezfx.Csv;

namespace Cars.CS
{

    [CsvObject(CodePage = 936, Description = "", HasHeader = true, Name = "", MappingType = CsvMappingType.Title, Delimiter = ",")]
    public class CarCsv
    {

        /// <summary>
        /// 0, Year
        /// </summary>
        [SystemCsvColumn(Name = "Year", Ordinal = 0, Alias = "")]
        public string Year { get; set; }


        /// <summary>
        /// 1, Make
        /// </summary>
        [SystemCsvColumn(Name = "Make", Ordinal = 1, Alias = "")]
        public string Make { get; set; }


        /// <summary>
        /// 2, Model
        /// </summary>
        [SystemCsvColumn(Name = "Model", Ordinal = 2, Alias = "")]
        public string Model { get; set; }


        /// <summary>
        /// 3, Length
        /// </summary>
        [SystemCsvColumn(Name = "Length", Ordinal = 3, Alias = "")]
        public string Length { get; set; }


    }
}

The VB code:

Imports Ezfx.Csv

<CsvObject(CodePage:=936, Description:="", HasHeader:=True, MappingType:=Ezfx.Csv.CsvMappingType.Title, Name:="", Delimiter:=",")> _
Public Class CarCsv

    ''' <summary>
    ''' 0, Year
    ''' </summary>
    <SystemCsvColumn(Alias:="", Ordinal:=0, Name:="Year")> _
    Public Property Year() As String


    ''' <summary>
    ''' 1, Make
    ''' </summary>
    <SystemCsvColumn(Alias:="", Ordinal:=1, Name:="Make")> _
    Public Property Make() As String


    ''' <summary>
    ''' 2, Model
    ''' </summary>
    <SystemCsvColumn(Alias:="", Ordinal:=2, Name:="Model")> _
    Public Property Model() As String


    ''' <summary>
    ''' 3, Length
    ''' </summary>
    <SystemCsvColumn(Alias:="", Ordinal:=3, Name:="Length")> _
    Public Property Length() As String

End Class

CSV Read

The following code reads a csv file and put data to Csv Objects.

CarCsv[] imdbs = CsvContext.ReadFile<ImdbCsv>("cars.csv");

You can also provide csv content as a string

CarCsv[] imdbs = CsvContext.ReadContext<CarCsv>("...");

Document Generator

With Document Generator, you can get the schema of the CSV files or the Excel and Access files and save the result to a CSV file for further edit.

References

CSV in Wikipedia: http://en.wikipedia.org/wiki/Comma-separated_values

CSV2Entity

Build status
Build Status

This Software REFUSE 996 Chinese Companies

996 ICU Save Chinese Developers

Install

Install Core from Nuget

Instial Visual Studio Extension from marketplace

https://marketplace.visualstudio.com/items?itemName=EricZhou.int123

To view the introduce Video please visit:

https://youtu.be/z3eB05DaQuI

What is CSV

CSV is the abbreviation of Comma-separated values, a file format stores tabular data in plain-text form, usually with .csv extension. CSV is a simple file format that is widely supported by consumer, business, and scientific applications.

Examples

Example of a USA/UK CSV file

Year,Make,Model,Length

1997,Ford,E350,2.34

2000,Mercury,Cougar,2.38

CSV Entity

In order to build CSV entities, we need something more. Csharp’s Attribute Mechanism provides us what we need by decorate CSV class properties with a custom attribute. Custom attribute defines CVS field’s display name and order. Here is the CsvFieldAttribute:

public class CsvFieldAttribute:Attribute

{

   public string Name { get; set; }

   public int Order { get; set; }

}

With CsvFieldAttribute, now we can decorate our own class.

[CsvObject(CodePage = 936, Description = "", HasHeader = true, Name = "")]
public class Car

{

   [SystemCsvColumn(Name = "Year", Order = 0)]

   public string Year { get; set; }

   [SystemCsvColumn(Name = "Make", Order = 1)]

   public string Make { get; set; }

   [SystemCsvColumn(Name = "Model", Order = 2)]

   public string Model { get; set; }

   [SystemCsvColumn(Name = "Length", Order = 3)]

   public string Length { get; set; }

}

Generate CSV Class

So, do we need to create CSV classes manually? Of cause not. So I developed the following tool to generate CSV classes:

To Generate CSV Classes, you have to install the VSIX file:

VSIX file

After the installation a new template called EZFX CSV Class will be displayed in your Visual Studio 2010 both in language VB and C#.

Add VB Class:

CS

Add C# Class:

CS

After click of add, a CSV Generation Wizard Window will be displayed, you can select a CSV file by click the browse button, this Wizard support Excel(xls, xlsx) and Access files(mdb, accdb), too. You specify the encoding for the CSV file and table name for Excel and Access file.

CSV Generation Wizard

The following is the generated file:

The C# code:

using Ezfx.Csv;

namespace Cars.CS
{

    [CsvObject(CodePage = 936, Description = "", HasHeader = true, Name = "", MappingType = CsvMappingType.Title, Delimiter = ",")]
    public class CarCsv
    {

        /// <summary>
        /// 0, Year
        /// </summary>
        [SystemCsvColumn(Name = "Year", Ordinal = 0, Alias = "")]
        public string Year { get; set; }


        /// <summary>
        /// 1, Make
        /// </summary>
        [SystemCsvColumn(Name = "Make", Ordinal = 1, Alias = "")]
        public string Make { get; set; }


        /// <summary>
        /// 2, Model
        /// </summary>
        [SystemCsvColumn(Name = "Model", Ordinal = 2, Alias = "")]
        public string Model { get; set; }


        /// <summary>
        /// 3, Length
        /// </summary>
        [SystemCsvColumn(Name = "Length", Ordinal = 3, Alias = "")]
        public string Length { get; set; }


    }
}

The VB code:

Imports Ezfx.Csv

<CsvObject(CodePage:=936, Description:="", HasHeader:=True, MappingType:=Ezfx.Csv.CsvMappingType.Title, Name:="", Delimiter:=",")> _
Public Class CarCsv

    ''' <summary>
    ''' 0, Year
    ''' </summary>
    <SystemCsvColumn(Alias:="", Ordinal:=0, Name:="Year")> _
    Public Property Year() As String


    ''' <summary>
    ''' 1, Make
    ''' </summary>
    <SystemCsvColumn(Alias:="", Ordinal:=1, Name:="Make")> _
    Public Property Make() As String


    ''' <summary>
    ''' 2, Model
    ''' </summary>
    <SystemCsvColumn(Alias:="", Ordinal:=2, Name:="Model")> _
    Public Property Model() As String


    ''' <summary>
    ''' 3, Length
    ''' </summary>
    <SystemCsvColumn(Alias:="", Ordinal:=3, Name:="Length")> _
    Public Property Length() As String

End Class

CSV Read

The following code reads a csv file and put data to Csv Objects.

CarCsv[] imdbs = CsvContext.ReadFile<ImdbCsv>("cars.csv");

You can also provide csv content as a string

CarCsv[] imdbs = CsvContext.ReadContext<CarCsv>("...");

Document Generator

With Document Generator, you can get the schema of the CSV files or the Excel and Access files and save the result to a CSV file for further edit.

References

CSV in Wikipedia: http://en.wikipedia.org/wiki/Comma-separated_values

Release Notes

fixed export bugs

Dependencies

This package has no dependencies.

This package is not used by any popular GitHub repositories.

Version History

Version Downloads Last updated
2.4.8 237 4/8/2019
2.2.8 148 2/3/2019
2.2.3 103 1/31/2019
2.2.0 127 1/29/2019
2.0.0 143 1/21/2019
1.0.0 216 1/12/2019