QuickCsv.Net
1.1.1
dotnet add package QuickCsv.Net --version 1.1.1
NuGet\Install-Package QuickCsv.Net -Version 1.1.1
<PackageReference Include="QuickCsv.Net" Version="1.1.1" />
paket add QuickCsv.Net --version 1.1.1
#r "nuget: QuickCsv.Net, 1.1.1"
// Install QuickCsv.Net as a Cake Addin #addin nuget:?package=QuickCsv.Net&version=1.1.1 // Install QuickCsv.Net as a Cake Tool #tool nuget:?package=QuickCsv.Net&version=1.1.1
CSV_Helper_Project
A csv library for loading/saving csv files relatively quickly and easily. This repository serves as a quick csv parser and editor, supporting the CSV standard, including multi-line cell values. As with all my projects, this library is focused on simplicity and speed. Test it for your own purposes.
Features
- CSV Standard Compliance: Supports standard CSV format, including multiline cell values.
- Ease of Use: Simplified methods for common CSV operations.
- Column Operations: Adding, removing, and renaming columns.
- Header Management: Handling headers and accessing cells by column name.
- Custom Delimiters: Support for custom delimiters in CSV files.
- Encoding Flexibility: Support for various non-standard encodings.
- Record Manipulation: Adding, removing, and inserting records.
- Streaming Records: Stream CSV records from a file, yielding one record at a time with
StreamCsvRecords
. - Writing Records: Write a single CSV record to an open
StreamWriter
withWriteCsvRecord
.
Not Supported Yet
- Automatic cell-to-type (e.g., cell → double) parsing.
- Automatic recognition of headers, encoding, and delimiter types.
- Automatic data type proofing (this is a string library for IO purposes).
Sample Usage
Creating and Writing to a Table
// create Table
Table allRunResults = new CSVHelper.Net.Table();
allRunResults.SetColumnNames(new[] { "ChestName", "Start Invest", ... });
// add data records
foreach (RunResult result in results)
{
int index = allRunResults.AppendEmptyRecord();
allRunResults.SetCell("ChestName", index, result.ChestName);
allRunResults.SetCell("Start Invest", index, startCash.ToString());
allRunResults.SetCell("Average Wagered Coins", index, result.WageredCoins.ToString());
allRunResults.SetCell("Average Survived Rounds", index, result.BettingRounds.ToString());
allRunResults.SetCell("Max Balance", index, result.MaxBalance.ToString());
}
// save the Table
allRunResults.WriteTableToFile("sample.csv");
reading from a table
Table allRunResults = new CSVHelper.Net.Table();
allRunResults.LoadFromFile("path/to/file.csv", hasHeaders: true);
RunResult[] results = new RunResult[allRunResults.Length];
for (int i = 0; i < allRunResults.Length; i++)
{
results[i] = new RunResult()
{
ChestName = runs.GetCell(i, "ChestName"),
BettingRounds = double.Parse(runs.GetCell(i, "Average Survived Rounds")),
WageredCoins = double.Parse(runs.GetCell(i, "Average Wagered Coins")),
MaxBalance = double.Parse(runs.GetCell(i, "Max Balance"))
};
}
modify a table
Table table = new Table();
// Set the column names of the table
string[] columnNames = new string[] { "ID", "Name", "Email" };
table.SetColumnNames(columnNames);
// Add a new record to the table
string[] record1 = new string[] { "1", "John Smith", "john@example.com" };
table.AppendRecord(record1);
// Add another record to the table
string[] record2 = new string[] { "2", "Jane Doe", "jane@example.com" };
table.AppendRecord(record2);
// Insert an empty record at the beginning of the table
table.InsertEmptyRecord(0);
// Remove the second record from the table
table.RemoveRecord(1);
// Overwrite the first record with new values
string[] updatedRecord = new string[] { "1", "John Doe", "john.doe@example.com" };
table.OverwriteOrInsertRecord(updatedRecord, "ID");
// Search for a record with the email "jane@example.com" and remove it if it exists
LookupValue lookup = new LookupValue("jane@example.com", "Email");
table.RemoveRecordIfExists(lookup);
streaming and writing directly to a csv file
var parser = new CSV_Helper_Project.Parser();
foreach (var record in parser.StreamCsvRecords("path/to/your/file.csv"))
{
// Process each record here
}
using (var writer = new StreamWriter("path/to/your/output.csv"))
{
var record = new string[] { "Field1", "Field2", "Field3" };
parser.WriteCsvRecord(writer, record);
}
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. 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 is compatible. 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 is compatible. 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. |
-
net6.0
- StringHelper.Net (>= 1.0.1)
-
net7.0
- StringHelper.Net (>= 1.0.1)
-
net8.0
- StringHelper.Net (>= 1.0.1)
NuGet packages (3)
Showing the top 3 NuGet packages that depend on QuickCsv.Net:
Package | Downloads |
---|---|
QuickStatistics.Net
a quick and lightweight library to grab statistics of live data on the fly |
|
PortfolioPerformanceTableHelper
a simple, flexible library for creating CSV entries compatible with Portfolio Performance software. It streamlines transaction management for multiple transaction types and securities. |
|
UnhandledExceptionLogger
this is a basic error logger which logs unhandled exceptions or user defined messages to a specified logfile in csv format and/or to console |
GitHub repositories
This package is not used by any popular GitHub repositories.
1.1.0
- finalize documentation comments
- null value return improvement
- add capability to stream records to/from file
- updated Parser documentation
1.0.6
- improves documentation
- improves an error message when a columnname could not be matched
1.1.0:
added Support for .Net 8.0
1.0.5:
- when saving, creates the directory first if it does not exist
1.0.4:
- Table.LoadFromFile now automatically updates the target path, so that save can be called easily.
1.0.3:
- added capability to store a target file name to the table and then call .Save()
- This can come in handy when dealing with collections of Tables
1.0.2:
- added a tracking variable which tracks if changes have been made to the table since last loading or saving it