Recent Changes - Search:

NetLogo

Erlang

R

PmWiki

edit SideBar

CSV

This model code shows how the CSV extension can be used to process a file containing a sequential stream of trades (commodities, forex, stocks, etc.)

The csv file might have a header row, giving the names of the columns, such as date, open, close, volume. The code below checks the first row for a string value in the last column. Not the first, because that is likely to be a date field and may be a string.

IMPORTANT!!!

Before running the program, you must examine the csv field structure of the data file you are going to use and you must modify the procedure "specifics-get-next-record" to match. The fields must be the same.

How it works

The datasource file is read in, and stored in the variable 'data': set data read-data user-file

The variable "data" is a list of lists. Movement is forward, by copying into "vals-list" the contents of the item in the list that corresponds to a variable "data-pointer" No part of the data file is removed from memory, so it would be possible to add code to move the data-pointer backwards.

If you are modifying the code, try to use the specific procedures (specific-setup and specific-go, as well as adjusting specifics-get-next-record) whenever possible. Whatever is placed in those procedures is added to the general setup and go procedures at the end of those sections.

Edit - History - Print - Recent Changes - Search
Page last modified on February 08, 2017, at 10:00 AM