load_csv

This function will load a CSV format file and convert it into a DS grid, returning the unique ID value for the grid created.

Your CSV file should follow the CSV specification. If your CSV syntax is not correct, you will get unexpected results on loading the file.

This will load each cell as a string, even if it only contains numbers. Use the function real to convert a string into number.

 

Syntax:

load_csv(filename)

Argument Type Description
filename String The name of the file to open (as a string)

 

Returns:

DS Grid

 

Example:

file_grid = load_csv("spreadsheet.csv");
var ww = ds_grid_width(file_grid);
var hh = ds_grid_height(file_grid);
var xx = 32;
var yy = 32;
for (var i = 0; i < ww; i++;)
{
    for (var j = 0; j < hh; j++;)
    {
        draw_text(xx, yy, file_grid[# i, j]);
        yy += 32;
    }
    yy = 32;
    xx += 32;
}

The above code will open the given CSV file and store the returned DS grid in the variable "file_grid". This grid is then parsed in a couple of for lops and the contents drawn to the screen.