Sion.CSVParse
2.0.0
Please use Sion.Useful.Files for your CSV needs. If there's a feature missing from the new package that you use, please request it on the GitHub repo.
dotnet add package Sion.CSVParse --version 2.0.0
NuGet\Install-Package Sion.CSVParse -Version 2.0.0
<PackageReference Include="Sion.CSVParse" Version="2.0.0" />
paket add Sion.CSVParse --version 2.0.0
#r "nuget: Sion.CSVParse, 2.0.0"
// Install Sion.CSVParse as a Cake Addin
#addin nuget:?package=Sion.CSVParse&version=2.0.0
// Install Sion.CSVParse as a Cake Tool
#tool nuget:?package=Sion.CSVParse&version=2.0.0
Sion.CSVParse
.NET 5 DLL that can be used to asynchronously parse .csv files and return the data.
How to use this DLL in your .NET 5 projects:
Using NuGet -
- Right click on the solution in Visual Studio.
- Click "Manage NuGet Packages for Solution".
- Search for "Sion.CSVParse" and install the latest package to the appropriate projects.
- Make sure to add "using Sion.CSVParse;" to the top of your .cs or .vb files.
Using a local folder -
- Download the most recent .dll file from this GitHub Repo's Releases.
- Move the recently downloaded "Sion.CSVParse.dll" file to a known location on your disk.
- In Visual Studio, with your project open, right click on "Dependencies" for the specific project you wish to install the DLL.
- In the popup menu, click "Add Project Reference...".
- A modal will pull up. Click the "Browse..." button towards the bottom right of the modal.
- Navigate to where you saved "Sion.CSVParse.dll" and add it.
- Make sure to add "using Sion.CSVParse;" to the top of your .cs or .vb files.
How to convert from .csv format to .json format (creates a new .json file):
await CSV.ConvertToJSON("filepath.csv", "filepath.json");
How to fill in empty values (this overwrites your .csv file):
await CSV.FillEmptyValues("filepath.csv", "none");
How to grab just the data from your .csv file:
If there are headers -
IEnumerable<IEnumerable<string>> data = await CSV.GetData("filepath.csv");
If there are no headers -
IEnumberable<IEnumberable<string>> data = await CSV.GetData("filepath.csv", false); // OR IEnumberable<IEnumberable<string>> data = await CSV.Parse("filepath.csv");
How to grab just the headers from your .csv file:
IEnumberable<string> headers = await CSV.GetHeaders("filepath.csv");
How to grab just the x values from my data:
IEnumerable<IEnumerable<string>> xValues = CSV.GetXValues(IEnumerable<IEnumerable<string>> dataset);
How to grab just the y values from my data:
IEnumerable<string> yValues = CSV.GetYValues(IEnumerable<IEnumerable<string>> dataset);
How to normalize the width of all rows (this overwrites your .csv file):
This pads each row with some value until they all have the same number of columns
await NormalizeWidth("filepath.csv", "0");
How to grab all the data, headers included (if there are headers):
IEnumberable<IEnumberable<string>> data = await CSV.Parse("filepath.csv");
How to replace a value throughout my .csv (this overwrites your .csv file):
await CSV.Replace("filepath.csv", "NULL", "0");
What if I use a character other than ',' to delimit my .csv files?:
All the methods are overloaded to accept an optional char delimiter! If not provided, ',' is the assumed character
CSV.GetXValues and CSV.GetYValues do not need a delimiter
What if I use an encoding other than UTF8 on my .csv files?:
All the methods are also overloaded to accept an optional Encoding. If not provided, UTF8 is the assumed encoding
CSV.GetXValues and CSV.GetYValues do not need an Encoding
All methods for CSV.ConvertToJSON:
public static async Task ConvertToJSON(string path, string jsonPath); public static async Task ConvertToJSON(string path, string jsonPath, Encoding encoding); public static async Task ConvertToJSON(string path, string jsonPath, char delimiter); public static async Task ConvertToJSON(string path, string jsonPath, char delimiter, Encoding encoding);
All methods for CSV.FillEmptyValues:
public static async Task FillEmptyValues(string path, string value); public static async Task FillEmptyValues(string path, string value, Encoding encoding); public static async Task FillEmptyValues(string path, string value, char delimiter); public static async Task FillEmptyValues(string path, string value, char delimiter, Encoding encoding);
All methods for CSV.GetData:
public static async Task<IEnumerable<IEnumerable<string>>> GetData(string path); public static async Task<IEnumerable<IEnumerable<string>>> GetData(string path, Encoding encoding); public static async Task<IEnumerable<IEnumerable<string>>> GetData(string path, char delimiter); public static async Task<IEnumerable<IEnumerable<string>>> GetData(string path, char delimiter, Encoding encoding); public static async Task<IEnumerable<IEnumerable<string>>> GetData(string path, bool hasHeaders); public static async Task<IEnumerable<IEnumerable<string>>> GetData(string path, bool hasHeaders, Encoding encoding); public static async Task<IEnumerable<IEnumerable<string>>> GetData(string path, bool hasHeaders, char delimiter); public static async Task<IEnumerable<IEnumerable<string>>> GetData(string path, bool hasHeaders, char delimiter, Encoding encoding);
All methods for CSV.GetHeaders:
public static async Task<IEnumerable<string>> GetHeaders(string path); public static async Task<IEnumerable<string>> GetHeaders(string path, Encoding encoding); public static async Task<IEnumerable<string>> GetHeaders(string path, char delimiter); public static async Task<IEnumerable<string>> GetHeaders(string path, char delimiter, Encoding encoding);
All methods for CSV.GetXValues:
public static IEnumerable<IEnumerable<string>> GetXValues(IEnumerable<IEnumerable<string>> dataset);
All methods for CSV.GetYValues:
public static IEnumerable<string> GetYValues(IEnumerable<IEnumerable<string>> dataset);
All methods for CSV.NormalizeWidth:
public static async Task NormalizeWidth(string path, string padValue); public static async Task NormalizeWidth(string path, string padValue, Encoding encoding); public static async Task NormalizeWidth(string path, string padValue, char delimiter); public static async Task NormalizeWidth(string path, string padValue, char delimiter, Encoding encoding);
All methods for CSV.Parse:
public static async Task<IEnumerable<IEnumerable<string>>> Parse(string path); public static async Task<IEnumerable<IEnumerable<string>>> Parse(string path, Encoding encoding); public static async Task<IEnumerable<IEnumerable<string>>> Parse(string path, char delimiter); public static async Task<IEnumerable<IEnumerable<string>>> Parse(string path, char delimiter, Encoding encoding);
All methods for CSV.Replace:
public static async Task Replace(string path, string replace, string newValue); public static async Task Replace(string path, string replace, string newValue, Encoding encoding); public static async Task Replace(string path, string replace, string newValue, char delimiter); public static async Task Replace(string path, string replace, string newValue, char delimiter, Encoding encoding);
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 is compatible. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
-
net5.0
- Newtonsoft.Json (>= 12.0.3)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|
Major update!
==============================================
New methods:
ConvertToJSON
NormalizeWidth
==============================================
Methods now accept an optional Encoding parameter.
==============================================
Please read the documentation.