Vishal.TextFileUtils - Library for working with delimited text file formats

by Vishal 10. July 2008 01:35

This is a very old piece of .net code that became very popular for some reason, so I'm posting it here in the legacy section.

A delimited file is a text file used to store un-typed data in a tabular form. It consists of a Header line and one or more LineEntries of data. Each line consists of a Value that is encased within what is known as a String Qualifier. Each encased value is then separated by a delimiter or Separator. At the end of every line is an EndLine string. Common examples are the CSV (Comma Separated Value) format and the Tab Delimited format.

So… I finally ended up writing a library that I’ve found to be immensely useful to me over the years. You can download it here! Its completely .Net, hasn’t failed me yet and can chop, slice, dice and grate delimited file formats. Common funcationality includes:

  1. Reading/ Writing Delimited Files
  2. Providing a library of strogly typed objects that define elements of a delimited text file
  3. Converting from one delimited format to another
  4. Defining your own custom file formats
  5. Re-ordering columns of a delimited file
  6. Re-naming columns of a delimited file
  7. Adding columns
  8. Removing columns
  9. Inserting columns
  10. Sorting columns
  11. Reversing columns

And more…  Before you start, Remember to add a reference to TextFileUtils.dll and add the line “using Vishal.TextFileUtils;” above your class. Here are some C# examples of how easy it is to work with delimited files: 

Reading/ Writing Delimited Files:


DelimitedFile df =  new DelimitedFile(new FileFormat(PredefinedFormats.CSV), @”C:\”);

foreach (LineEntry le in df)




for (int i = 0; df.Count; i++)     


    le.FieldValues[“MyColumnName”]= “MyColumnData”;



Converting from one format to another: 

// One line of code!

FileUtil.ConvertFile(@”C:\somefile.txt”, new FileFormat(PredefinedFormats.CSV), @”C:\Output.txt”, new FileFormat(PredefinedFormats.TAB)); 

// One line of code with custom formats!

FileUtil.ConvertFile(@”C:\somefile.txt”, new FileFormat(“\”", “,”, “\r\n” ), @”C:\Output.txt”, new FileFormat(“”, “\t”, “\r\n”);

Removing, Renaming, Inserting, Reordering, Sorting, Adding Columns

// Read File

DelimitedFile df =  new DelimitedFile(new FileFormat(PredefinedFormats.CSV), @”C:\”);

// Remove a column called “MyColumn”


// move a column called “MyOtherColumn” to the 5th position

df.MoveColumn(“MyOtherColumn”, 5); 

// sort the columns alphabetically 


// Insert a column called “MyFirstColumn” at position 0

df.InsertColumn(0, “MyFirstColumn”); 

// Rename a column called “OldColumnName” to “NewColumnName”

df.RenameColumn(“OldColumnName”, “NewColumnName”); // Reverse the columns in the file


// Re-order the columns to your liking

List<string> OldColumnsList = df.GetColumnNamesList();     

// {Code to Re-Order OldColumnList here}


// Save the file!


The library has much more. For the complete specifications refer to the TextFileUtils.chm help file. If you have any comments, questions or improvements, you can post them here or email me.

Download TextFileUtils version



Add comment

  Country flag
  • Comment
  • Preview

Repliques Montres haute qualite vous aider a economiser beaucoup tout en appreciant la valeur du nom de marque. Vous voulez avoir cette montre luxe haut de gamme suisses sur votre main, mais replica uhren l'achat d'une voiture semble une meilleure option. Oui, c'est la realite. Ces montres symbole de statut social co?tent quelque chose replicas de relojes qui est au-dela pour permettre pour une personne normale. Mais ne desesperez hublot replique montres pas si vous ne pouvez pas vous permettre d'acheter ces montres de luxe. Vous avez une belle occasion d'acheter des montres de prestige nom Replique de la marque. Certaines personnes aiment l'aspect d'un veritable montres au poignet, ou replique rolex montres voulez juste nombreuses montres de marque pour correspondre a leur habillement, mais evitez patek philippe replica orologi de depenser des milliers de dollars que une vraie montre mai cots, ils se tournent vers les replique montre montres bonne replique. Si vous ne voulez pas acheter des montres de veritables montres de haute qualite puis de replicas sont votre choix ideal.