40 lines
698 B
Rexx
Executable File
40 lines
698 B
Rexx
Executable File
#!/usr/bin/env rexx
|
|
/* Rexx */
|
|
|
|
csv = .csvStream~new('headered.csv', .true)
|
|
csv~open
|
|
|
|
/* Stream class defaults to both ie:readWrite */
|
|
myTable = .table~new
|
|
myTable~put('red','colour')
|
|
myTable~put('stop','action')
|
|
|
|
csv~CSVLineout(myTable)
|
|
myTable~put('green','colour')
|
|
myTable~put('go','action')
|
|
|
|
csv~CSVLineout(mytable)
|
|
myTable~put('yellow', 'colour')
|
|
myTable~put('decelerate', 'action')
|
|
|
|
csv~CSVLineout(myTable)
|
|
csv~close
|
|
|
|
/* Read it back */
|
|
Csv~open('read')
|
|
Do while csv~chars > 0
|
|
Csv~csvLineIn
|
|
Say 'new record'
|
|
Do field over csv~values
|
|
Say field':' csv~values~at(field) /* colour: green */
|
|
End
|
|
End
|
|
/*======================*/
|
|
csv~close
|
|
|
|
Exit
|
|
|
|
::requires 'csvStream.cls'
|
|
|
|
|