The following snippet gets value from csv-file and write it to Error log.
You can just replace command "log" be needed commands in the line "get-value $table
"a1"
0
| log" and use the value of table for your purpose.
Procedures "index-of" and "get-value" can be added to ECL context.
proc "index-of" [val list -input] [val item] {
$list | each [val elem] [val index] {
if [$elem | eq $item] { $index }
} | to-list | get 0 [ int "-1" ]
}
proc "get-value" [val table] [val columnName] [val rowNumber] { // this proc return value from columnName column rowNumber row
let [val columnIndex [$table | get columns | to-list | index-of $columnName]] {
$table | get rows | to-list
| get $rowNumber | get values |to-list
| get $columnIndex
}
}
let [val table [read-csv-file "file:/temp/read-csv.csv" ]] { // read table from csv-file
get-value $table "a1" 0 | log // this line write to Error log value from column a1 row 0
}
|
With the table:
a1,b1
1,2
this snippet will write to Error log value 1.