Skip to main content

CSV

SA Engine supports several ways to save and load data. One of the easiest ways is using Comma Separated Value (CSV) files. Any Stream of Vector or Bag of Vector can be saved to a CSV log file recording using one of the csv:write_file functions:

signature(apropos("csv:write_file"));
Not connected

To run this code block you must be logged in and your studio instance must be started.

Each row written to a CSV file is a vector. For instance to save 10 rows where each row has a number from 1 to 10 the following query can be used:

csv:write_file("test.csv",(select [i]
from Number i
where i in iota(1,10)))
Not connected

To run this code block you must be logged in and your studio instance must be started.

You can convert a CSV log file to a live vector stream by calling csv:file_stream, for example:

csv:file_stream("test.csv");
Not connected

To run this code block you must be logged in and your studio instance must be started.

To save a stream to a CSV log file and at the same time get the output, set the feedback argument to 1:

csv:write_file("test.csv",1,(select [i, sin(i)]
from Number i
where i in iota(1,10)))
Not connected

To run this code block you must be logged in and your studio instance must be started.

csv:file_stream("test.csv");
Not connected

To run this code block you must be logged in and your studio instance must be started.

Functions

csv:file_stream(Charstring file,Charstring option)->Stream of Vector

Stream tuples from CSV file. option is one of read, loop, or tail


csv:file_stream(Charstring file,Charstring option,Number pace)->Stream of Vector

Playback CSV file in a specified pace. The option is one of read, loop, or tail


csv:file_stream(Charstring file)->Stream of Vector

Stream tuples from CSV file


csv:from_string(Charstring row)->Vector

Read CSV from a charstring


csv:load(Charstring model,Charstring file)->Charstring

Load exported functions from CSV file in model


csv:popen_stream(Charstring command)->Stream of Vector

Call an OS command that produces a CSV stream on standard output


csv:serial_stream(Charstring sn,Integer br)->Stream of Vector

CSV stream from serial port named sp with baud rate br


csv:serial_stream(Charstring sn,Integer br,Charstring flow_control,
Integer data_bits,Integer stop_bits,Integer parity)
->Stream of Vector

CSV stream from serial port named sp with baud rate br


csv:socket_stream(Charstring host,Integer sp,Object request)->Stream of Vector

CSV stream from port sp on host


csv:socket_stream(Charstring host,Integer sp)->Stream of Vector

CSV stream from port sp on host


csv:unload(Charstring fn,Charstring model,Charstring file)->Charstring

Unload function named fn into CSV file in model


csv:unload(Vector of Function fv,Charstring model,Charstring file)->Charstring

Unload functions in fv into CSV file in model


csv:write_file(Charstring file,Bag b)->Boolean

Write bag of vectors b into file in CSV format


csv:write_file(Charstring file,Stream s)->Boolean

Write Stream of vectors s into file in CSV format


csv:write_file(Charstring file,Number feedback,Bag b)->Bag of Vector

Write bag of vectors b into file in CSV format. Return the row every feedback rows


csv:write_file(Charstring file,Number feedback,Stream s)->Stream of Vector

Write Stream of vectors s into file in CSV format. Return saved rows every feedback rows