Using CSV Data
You can deploy auxiliary data from CSV-files in todo4teams and evaluate these in your scripts. CSV-files contain tabular data, which may be compared to Excel spreadsheets. You can store any Excel spreadsheet in the CSV-format.
The following procedures help to realize lookup-functions in todo4teams. Imagine, for example, that you have created a table that maps in a two-column view hundreds of product names to the names of the teams to which the respective service requests should be routed.
The content of this CSV file is stored in the "Server-Settings" in which you should specify a key "ProduktZuGruppeCSV" and copy 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.
if(helper.getCsvDataCache("myCache")==null)
{
// CSV-Cache mit dem Namen myCache erzeugen:
helper.createCsvDataCacheFromString("myCache", helper.getServerPropertyByName("ProduktZuGruppeCSV"));
}
// CSV-Cache ermitteln:
var cache = helper.getCsvDataCache("myCache");
// Suche nach dem Wort produktname in der ersten Spalte der Tabelle
// und Rückgabe des Wertes aus der Spalte mit dem Titel „Gruppe“:
var gruppe = cache.getLookupContainsValue(produktname,"Gruppe");
println("Gruppe : "+gruppe);
The functions in detail:
Creates a CSV cache from the CSV data in the string csvData and saves it under the name cacheName.
public void createCsvDataCacheFromString(String cacheName, String csvData)
Creates a CSV cache by loading the CSV data from a URL (e.g. http://fileserver/daten/produkte.csv or file://home/daten/produkte.csv) and stores it under the name cacheName.
Determines a CSV cache with the name cacheName. If no cache with this name has been created yet, null is returned.
public CsvDataCache getCsvDataCache(String cacheName)
Methods of the CsvDataCache object:
Searches for a row of the CSV file in this cache that contains the value lookup in the first column and returns the row value from the column that has the value (column name) column in the first row.
CsvDataCache.getLookupContainsValue(String lookup, String column)
If you now run the above code with the following Excel file, “Service Software” is returned as the result.
CSV-Datei:
Produktname | Gruppe |
---|---|
AX-500 | Service-Hardware |
CF-Plus | Service-Software |
FG-150 | Kundendienst |
Like get Lookup Contains Value(), but here lookup exact is compared with the column contents.
CsvDataCache.getLookupValue(String lookup, String column)