Page cover

Name Split

In this simple example, We show how to load in a source file, split the name column into it's first and surnames, then re-save the file.

//Read file, add first and last name
var tblname = Transformer.TableFromFile(@"InputFile.csv");
tblname.Columns.Add("FirstName", typeof(string));
tblname.Columns.Add("LastName", typeof(string));

//Run an Fx expression over both new columns, splitting up the FullName into it's first and surnames
tblname.FxTable(new Dictionary<string, string>() {
    {"FirstName", "name([FullName], 'first')" },
    { "LastName", "name([FullName], 'surname')" }});

//Resave the CSV!
File.WriteAllText(@"Outfile.csv", tblname.ToCSV());

Last updated