CSV Splitter

A nifty command line tool to split up a csv file, based on column values.
http://csvfix.byethost5.com/csvfix.htm
It has many features, but I used it for it’s very efficent file splitting function.

The file_split command splits a CSV input stream into a number of files based on the values of specified fields in the CSV input stream. All the CSV records with the same values for those fields will be placed in the same file. By default, the created files are numbered, but you can also generate files based on the contents of the fields used to perform the split. Unlike most other CSVfix commands, this command does not write anything to standard output, or to any file specified by the -o flag.

Note that any existing files will be overwritten by this command, without warning. Use the -fd flag to locate the output files, and the -fp and -fx flags to name them.

-f fields (Required) : Comma-separated list of filed indexes on which to base the split.
-fd dir : Specifies the directory in which to place the results of the split. Defaults to the current directory.
-fp prefix : Specifies the prefix to use when constructing file names. Default is file_
-fx ext : Specifies the extension to use when constructing file names. The default is csv
-ufn : Use the contents of the field(s) specified by the -f flag to generate file names. No check is made that the fields contain valid filename components, and the command will fail if they do not.

The following example splits the cities.csv file based on the second field, which contains the country code.

csvfix file_split -f 2 data/cities.csv

This produces the following files, each of which contains the cities for a particular country:

file_0001.csv
file_0002.csv
file_0003.csv
file_0004.csv
file_0005.csv
file_0006.csv

With the same data, the following example:

csvfix file_split -f 2 -ufn data/cities.csv

uses the country code values to generate the file names, producing:

file_DE.csv
file_FR.csv
file_GB.csv
file_GR.csv
file_IT.csv
file_NL.csv

Here, file_DE.csv will contain German cities, file_FR.csv French cities, and so on.

Visual Studio 2010 : Looping tests using CSV input

To do this, you need to adjust the Test Settings, available in the Test menu.  If you leave the default settings, and you are using csv input, the test will only run once (i.e. take the first line from csv file).

Within dialog, select Web test then “One run per data source row”

It is recommended to use “Save As …” option, so you keep the original setting intact. Then to switch the test settings as/when needed.