CsvUtility 1.4.3

dotnet add package CsvUtility --version 1.4.3
NuGet\Install-Package CsvUtility -Version 1.4.3
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.3" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add CsvUtility --version 1.4.3
#r "nuget: CsvUtility, 1.4.3"
#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.3

// Install CsvUtility as a Cake Tool
#tool nuget:?package=CsvUtility&version=1.4.3
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 or prepare some appropriate csv files
	
	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 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.3 108 1/23/2024
1.4.2 183 11/27/2023
1.4.1 107 11/26/2023
1.4.0 102 11/25/2023
1.3.0 148 7/16/2023
1.2.9 128 6/30/2023
1.2.8.1 310 11/15/2022
1.2.8 296 11/14/2022
1.2.7 346 10/8/2022
1.2.5 400 7/16/2022
1.2.4 413 7/10/2022
1.2.2 401 6/30/2022
1.2.1 393 6/18/2022
1.2.0 402 5/9/2022
1.1.8 403 4/16/2022
1.1.7 406 3/17/2022
1.1.6 415 2/16/2022
1.1.5 399 2/6/2022
1.1.4 399 1/21/2022
1.1.3 411 1/19/2022
1.1.2 406 1/18/2022
1.1.1 243 12/29/2021
1.1.0 272 11/23/2021
1.0.9 314 10/27/2021
1.0.8 292 10/18/2021
1.0.7 293 10/13/2021