VB.NET/CSV File – How to add ‘Double quote text qualifiers’ quickly and easily!

Text qualifiers are used to let a program know that anything between a certain character should be interpreted as it is (Normally text). If you don’t get what ‘adding double quote text qualifier in a csv file’ means; In simple terms this will change a line like this: email,fname,lname,ipaddress to: “email”,”fname”,”lname”,”ipaddress”. Very simple.

I recently found out that I could not add double quotes to his CSV file that contained data I needed to upload. I looked around and the only actual thing I could find was a command prompt style replacer, which doesn’t suite a clients need for simplicity. Programs like Microsoft Excel seem to not want to add double quote text qualifiers in your CSV files, and in some cases will remove the automatically. The download links will be below.

I quickly created my own little VB.NET program to handle adding double quote text qualifiers that is user friendly. It will add double quotes to the beginning, end, and between each delimiter you specify. Currently, there are only a set group of delimiters to pick from, and I didn’t want to get fancy (Custom delimiter) to confuse the customer. This program will in no way ever overwrite a existing file as well so it should be safe to handle with. If you specify the file “Test.csv”, the output file will be “Test-1.csv”, or “Test-2.csv”, etc, depending on what ‘number’ is a free file. It will also handle VERY LARGE FILES because it processes per line rather then the traditional/stupid way of saving everything to an array. This means it is also very fast! I did not add a process bar however as I didn’t want to bother counting the lines before processing a file. More time wasted. Instead, it uses a simple label to display the status of where it is at.

I will provide the source so you can modify the program at will and make it even more fancier. This is very basic and I whipped it up in under 20 minutes. It should contain basic comments so you know what everything does. Hopefully this helps someone!

Here is the executable which can be run in Windows 7/Windows Vista. Should work in XP as well: QuoteAdder v1
Here is the source if you want to modify it or check it out: QuoteAdder Source


Related posts:

  1. DirectX: Trouble with double values not returning a proper precision value after initializing DirectX?
  2. PHP: Randomizing a text file using PHP + MYSQL, quickly & efficient
  3. PHP: Easy to use logging class for your scripts.
  4. Modified: Solmetra Flash Uploader v1.02 (to multi-file uploader) & A quick way to pass variables.

About the Author

I mainly focus on Javascript/PHP/C++/.NET applications for everyday and work. I also am working on a remake of Stellar Frontier, an old 2D top down space battle game with a few fellow programmers.