CsvUtility 1.4.5

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

// Install CsvUtility as a Cake Tool
#tool nuget:?package=CsvUtility&version=1.4.5                
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()
		{
			string lastdir = Application.StartupPath;
			TabControl tabControl = new TabControl() { Parent = this, Dock = DockStyle.Top, };
			tabControl.ContextMenuStrip = new ContextMenuStrip();
			ToolStripMenuItem toolStripMenuItemCloseTab = new ToolStripMenuItem() { Text="Close tab",};
			toolStripMenuItemCloseTab.Click += (sender, e) => 
			{
				var st = tabControl.SelectedTab;
				if(st !=default(TabPage))
				{
					tabControl.TabPages.Remove(st);
				}
			};
			tabControl.ContextMenuStrip.Items.Add(toolStripMenuItemCloseTab);

			MenuStrip menuStrip = new MenuStrip() { Parent = this, };
			ToolStripMenuItem toolStripMenuItemFile = new ToolStripMenuItem() { Text = "File", };

			Action<string, bool> Open = (filename, forcecsv) =>
			 {
				 lastdir = System.IO.Path.GetDirectoryName(filename);

				 TabPage page = new TabPage() { Text = System.IO.Path.GetFileName(filename), };

				 CsvFileV2 csv = forcecsv ? CsvFileV2.OpenAsCsv(filename) : CsvFileV2.Open(filename);
				 ToolStripMenuItem toolStripMenuItemSaveAs = new ToolStripMenuItem()
				 {
					 Text = "Save as csv",
					 BackColor = Color.LightYellow,
					 Alignment = ToolStripItemAlignment.Right,
				 };

				 toolStripMenuItemSaveAs.Click += (sender2, e2) =>
				 {
					 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();
						 }
					 }
				 };
				 csv.ToolStrip.Items.Add(toolStripMenuItemSaveAs);

				 ToolStripMenuItem toolStripMenuItemShowInfo = new ToolStripMenuItem()
				 {
					 Text = "Info",
					 BackColor = Color.LightYellow,
					 Alignment = ToolStripItemAlignment.Right,
				 };
				 toolStripMenuItemShowInfo.Click += (sender, e) =>
				 {
					 Form f = new Form() { Text = "Info", StartPosition = FormStartPosition.CenterScreen, };
					 ListBox listBox = new ListBox() { Parent = f, Dock = DockStyle.Fill, };
					 listBox.Items.Clear();
					 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]));
					 }
					 f.ShowDialog();

				 };
				 csv.ToolStrip.Items.Add(toolStripMenuItemShowInfo);


				 ToolStripMenuItem toolStripMenuItemGlimpse = new ToolStripMenuItem()
				 {
					 Text = "Glimpse",
					 BackColor = Color.LightYellow,
					 Alignment = ToolStripItemAlignment.Right,
				 };

				 toolStripMenuItemGlimpse.Click += (sender, e) => 
				 {
					 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;
					 }
				 };

				 csv.ToolStrip.Items.Add(toolStripMenuItemGlimpse);

				 page.Controls.Add(csv.Panel);

#if true
				 csv.Panel.Dock = DockStyle.Fill;
#else
					page.SizeChanged += (snder2, e2) => 
					{
						csv.Panel.Height = page.ClientSize.Height;
					};
#endif
				 tabControl.TabPages.Add(page);
				 tabControl.SelectTab(page);
			 };

			ToolStripMenuItem toolStripMenuItemOpen = new ToolStripMenuItem() { Text = "Open(Auto)", };
			toolStripMenuItemOpen.Click += (sender, e) =>
			{
				OpenFileDialog ofd = new OpenFileDialog() { InitialDirectory = lastdir, };
				if (ofd.ShowDialog() == DialogResult.OK) { Open(ofd.FileName, false); }
			};
			toolStripMenuItemFile.DropDownItems.Add(toolStripMenuItemOpen);
			ToolStripMenuItem toolStripMenuItemOpenAsCsv = new ToolStripMenuItem() { Text = "Open(Force as csv)", };
			toolStripMenuItemOpenAsCsv.Click += (sender, e) =>
			{
				OpenFileDialog ofd = new OpenFileDialog() { InitialDirectory = lastdir, };
				if (ofd.ShowDialog() == DialogResult.OK) { Open(ofd.FileName, true); }
			};
			toolStripMenuItemFile.DropDownItems.Add(toolStripMenuItemOpenAsCsv);
			toolStripMenuItemFile.DropDownItems.Add(new ToolStripSeparator());


			ToolStripMenuItem toolStripMenuItemParse = new ToolStripMenuItem() { Text = "Parse from clipboard", };
			toolStripMenuItemParse.Click += (sender, e) =>
			{
				var text = Clipboard.GetText();

				if (!string.IsNullOrEmpty(text))
				{
					try
					{
						var csv = CsvFileV2.Parse(text);
						TabPage page = new TabPage() { Text = string.Format("{0:yyyyMMdd_HHmmss}", DateTime.Now), };
						page.Controls.Add(csv.Panel);
						csv.Panel.Dock = DockStyle.Fill;

						tabControl.TabPages.Add(page);
						tabControl.SelectTab(page);
					}
					catch(Exception exception)
					{
						MessageBox.Show(exception.Message);
					}
				}

			};
			toolStripMenuItemFile.DropDownItems.Add(toolStripMenuItemParse);


			menuStrip.Items.Add(toolStripMenuItemFile);


			SizeChanged += (sender, e) =>
			{
				tabControl.Height = ClientSize.Height - menuStrip.Height;
			};

			StartPosition = FormStartPosition.CenterScreen;
			ClientSize = new Size(800, 600);

			Text = "CsvUtilityTester";
		}
	}
}
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.5 120 5/8/2024
1.4.4 114 4/27/2024
1.4.3 158 1/23/2024
1.4.2 214 11/27/2023
1.4.1 134 11/26/2023
1.4.0 134 11/25/2023
1.3.0 174 7/16/2023
1.2.9 159 6/30/2023
1.2.8.1 335 11/15/2022
1.2.8 320 11/14/2022
1.2.7 366 10/8/2022
1.2.5 431 7/16/2022
1.2.4 438 7/10/2022
1.2.2 426 6/30/2022
1.2.1 411 6/18/2022
1.2.0 437 5/9/2022
1.1.8 433 4/16/2022
1.1.7 439 3/17/2022
1.1.6 441 2/16/2022
1.1.5 413 2/6/2022
1.1.4 421 1/21/2022
1.1.3 432 1/19/2022
1.1.2 434 1/18/2022
1.1.1 276 12/29/2021
1.1.0 295 11/23/2021
1.0.9 336 10/27/2021
1.0.8 309 10/18/2021
1.0.7 318 10/13/2021