C#.Net Core: Import/Export CSV Library
I have previously created a simple C#.NET nuget library for importing/exporting CSV data using Datatable as a primary data structure. Now, I have migrated this library exclusively for C#.NET Core projects into a separate nuget library i.e. CSVLibraryAK.Core.
Today, I shall be demonstrating the basic use of my .NET Core Nuget library for importing/exporting CSV data using Datatable as a primary data structure.
1) Create a new Console Application project and name it "CSVImportExport".
Today, I shall be demonstrating the basic use of my .NET Core Nuget library for importing/exporting CSV data using Datatable as a primary data structure.
Prerequisites:
Following are some prerequisites before you proceed any further in this tutorial:- Install CSVLibraryAK.Core NuGet library.
- Knowledge of C# Programming.
Download Now! Nuget Installation
Let's begin now.1) Create a new Console Application project and name it "CSVImportExport".
2) Install 'CSVLibraryAK.Core' Nuget library into your project.
3) Create "CSVImportExport.cs" file and in the main method add following lines of code i.e.
... using CSVLibraryAK.Core; ... // Impot CSV file. DataTable data = CSVLibraryAK.Import(importFilePath, hasHeader); // Export CSV file. CSVLibraryAK.Export(exportFilePath, data); ...
In the above code, I am simply importing my target CSV file into DataTable data structure and then export my data from DataTable data structure to my destination CSV file using my CSVLibraryAK.Core Nuget library.
4) Now, execute the project and you will be able to see the export file in your target destination folder.
Post a Comment