Using CSV data


You can provide auxiliary data from CSV files in todo4teams and evaluate it in your scripts. CSV files contain tabular data, comparable to simple Excel tables. You can save any Excel table in CSV format.

The following functions are suitable for implementing lookup functions in todo4teams. Imagine, for example, that you have created a table that assigns the names of the ten todo groups to several hundred product names in a two-column view to which the respective service requests should be directed.

You save the contents of this CSV file in todo4teams in the "Server Settings" section by entering "product2group.csv" as the key and copying the file contents into the "Value" field.

The following example creates a so-called CSV cache from this server setting and then reads the name of the todo group for a product name from the CSV content.

// Prüfen, ob der CSV-Cache bereits existiert:
if(helper.getCsvDataCache("product2group")==null)
{
   // CSV-Cache mit dem Namen myCache erzeugen:
   helper.createCsvDataCacheFromString("product2group", helper.getServerPropertyByName("product2group.csv"));
}

// CSV-Cache ermitteln:
var cache = helper.getCsvDataCache("product2group");

// Suche nach dem Wort produktname in der ersten Spalte der Tabelle
// und Rückgabe des Wertes aus der Spalte mit dem Titel „Gruppe“:
var group = cache.getLookupContainsValue("FG-150","Group");
println("Group :  "+group);

Let's have a look at this crucial line of code:

var group = cache.getLookupContainsValue("FG-150","Group");

It looks up the value 'FG-150' in the first column of the CSV data and then returns the corresponding value form the column named 'Group' (see above).

...