Please enable JavaScript to view this site.

A-Shell 6.5 Development Notes

An entire CSV file can be loaded into a gridmap in a single step using:

input csv #ch, $gridmap()

For the gridmap(int; int; varstr) variation, the values will all be indexed by numeric row and column, each index starting from 1. The number of columns in each row may vary.

For the gridmap(int; varstr; varstr) variation, the first row of the CSV is assumed to contain the column headers, which are used for indexing the columns by name. In that case the second physical row of the CSV will be treated as row one. The application can determine the column names by iterating across the first row, using the .key($$i,1) function to check when the row number changes. The following example copies the column names from row one into a separate array:

dimx colnames$(0),s,40,auto_extend

dimx $csvmap, gridmap(int; varstr; varstr)

map1 col,i,2

...

input csv #ch, $csvmap()

foreach $$i in $csvmap()

    if .key($$i,1) = 1 then   ! if row 1

        col += 1

        colnames$(col) = .key($$i,2)

    else

        exit    ! quit when we hit the next row

    endif

next $$i