CsvUtility 1.4.0
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package CsvUtility --version 1.4.0
NuGet\Install-Package CsvUtility -Version 1.4.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="CsvUtility" Version="1.4.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add CsvUtility --version 1.4.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: CsvUtility, 1.4.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install CsvUtility as a Cake Addin #addin nuget:?package=CsvUtility&version=1.4.0 // Install CsvUtility as a Cake Tool #tool nuget:?package=CsvUtility&version=1.4.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using CsvUtility;
namespace CsvUtilityTest
{
/**
Paste below and save as .csv
seq,id,name,gender,birthday,remark
0,10001,Foo,male,1970/10/1,
1,10002,Bar,male,1980/2/1,test
2,10003,John,male,1990/3/15,
3,10004,Sophia,female,2000/12/5,
Or,
"seq","id","name","gender","birthday","remark"
"0","10001","Foo","male","1970/10/1",""
"1","10002","Bar","male","1980/2/1","test"
"2","10003","John","male","1990/3/15",""
"3","10004","Sophia","female","2000/12/5",
Also can use \t insted of comma
*/
public partial class CsvUtilityTest : Form
{
public CsvUtilityTest()
{
CsvFileV2 _csv = null;
ListBox listBox = new ListBox() { Parent = this, Dock = DockStyle.Top, };
Button buttonOutput = new Button() { Parent = this, Dock = DockStyle.Top, Text = "Write as a csv", };
buttonOutput.Click += (sender, e) =>
{
if (_csv != null)
{
SaveFileDialog sfd = new SaveFileDialog()
{
InitialDirectory = Application.StartupPath,
FileName = string.Format("{0:yyyyMMdd_HHmmss}", DateTime.Now),
DefaultExt = ".csv",
};
if (sfd.ShowDialog() == DialogResult.OK)
{
using (System.IO.StreamWriter sw = new System.IO.StreamWriter(sfd.FileName))
{
foreach (var l in _csv.AllLinesAsArray)
{
sw.WriteLine(CsvHelper.ToCsvFormat(l));
}
sw.Close();
}
}
}
else
{
MessageBox.Show("Open or parse first.");
}
};
Button buttonShowEachLine = new Button() { Parent = this, Dock = DockStyle.Top, Text = "Show each line", };
buttonShowEachLine.Click += (sender, e) =>
{
if (_csv != null)
{
foreach (var l in _csv.AllLinesAsArray)
{
List<string> list = new List<string>() { "Show next line?" };
for (int i = 0; i < l.Length; i++)
{
list.Add(string.Format("{0}={1}", _csv.OriginalHeader[i], l[i]));
}
var ret = MessageBox.Show(string.Join(Environment.NewLine, list), "Line", MessageBoxButtons.YesNo);
if (ret == DialogResult.No) break;
}
}
else
{
MessageBox.Show("Open or parse first.");
}
};
Button buttonView = new Button() { Parent = this, Dock = DockStyle.Top, Text = "View", };
buttonView.Click += (sender, e) =>
{
if (_csv != null)
{
_csv.ShowDialog();
}
else
{
MessageBox.Show("Open or parse first.");
}
};
Button buttonParse = new Button() { Parent = this, Dock = DockStyle.Top, Text = "Parse a text as a csv file", };
buttonParse.Click += (sender, e) =>
{
var ofd = new OpenFileDialog() { InitialDirectory = Application.StartupPath, };
if (ofd.ShowDialog() == DialogResult.OK)
{
try
{
using (System.IO.StreamReader sr = new System.IO.StreamReader(ofd.FileName, Encoding.UTF8))
{
_csv = CsvFileV2.Parse(sr.ReadToEnd());
listBox.Items.Clear();
listBox.Items.Add(string.Format("Parse {0}", ofd.FileName));
listBox.Items.Add("[Unique header]");
listBox.Items.AddRange(_csv.UniqueHeader);
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
};
Button buttonOpen = new Button() { Parent = this, Dock = DockStyle.Top, Text = "Open an csv file", };
buttonOpen.Click += (sender, e) =>
{
var ofd = new OpenFileDialog() { InitialDirectory = Application.StartupPath, };
if (ofd.ShowDialog() == DialogResult.OK)
{
_csv = CsvFileV2.Open(ofd.FileName);
listBox.Items.Clear();
listBox.Items.Add(string.Format("Open {0}", ofd.FileName));
listBox.Items.Add(string.Format("Delimiter={0}", _csv.Delimiter));
listBox.Items.Add(string.Format("Encoding={0}", _csv.Encoding));
listBox.Items.Add(string.Format("Line count={0}", _csv.LineCount));
listBox.Items.Add("[header]");
for (int i = 0; i < _csv.OriginalHeader.Length; i++)
{
listBox.Items.Add(string.Format(" originall={0}, unique={1}", _csv.OriginalHeader[i], _csv.UniqueHeader[i]));
}
}
};
SizeChanged += (sender, e) =>
{
listBox.Height = ClientSize.Height - buttonOpen.Height - buttonView.Height - buttonShowEachLine.Height;
};
StartPosition = FormStartPosition.CenterScreen;
Size = new Size(800, 600);
}
}
}
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET Framework | net461 is compatible. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
.NETFramework 4.6.1
- No dependencies.
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 |
---|---|---|
1.4.5 | 136 | 5/8/2024 |
1.4.4 | 119 | 4/27/2024 |
1.4.3 | 165 | 1/23/2024 |
1.4.2 | 219 | 11/27/2023 |
1.4.1 | 139 | 11/26/2023 |
1.4.0 | 139 | 11/25/2023 |
1.3.0 | 180 | 7/16/2023 |
1.2.9 | 165 | 6/30/2023 |
1.2.8.1 | 343 | 11/15/2022 |
1.2.8 | 328 | 11/14/2022 |
1.2.7 | 377 | 10/8/2022 |
1.2.5 | 440 | 7/16/2022 |
1.2.4 | 447 | 7/10/2022 |
1.2.2 | 434 | 6/30/2022 |
1.2.1 | 419 | 6/18/2022 |
1.2.0 | 447 | 5/9/2022 |
1.1.8 | 441 | 4/16/2022 |
1.1.7 | 447 | 3/17/2022 |
1.1.6 | 449 | 2/16/2022 |
1.1.5 | 423 | 2/6/2022 |
1.1.4 | 430 | 1/21/2022 |
1.1.3 | 440 | 1/19/2022 |
1.1.2 | 442 | 1/18/2022 |
1.1.1 | 286 | 12/29/2021 |
1.1.0 | 303 | 11/23/2021 |
1.0.9 | 344 | 10/27/2021 |
1.0.8 | 318 | 10/18/2021 |
1.0.7 | 328 | 10/13/2021 |