Data Import and Export#
General data loading#
Note
loadd and saved are recommended for most cases when working with the following file types:
GAUSS, SAS, Stata and SPSS datasets.
CSV and Excel files with variable names in the first row.
Returns the variable names from a dataset as a string array. |
|
Loads data into a GAUSS dataframe. The supported dataset types are CSV, Excel (XLS, XLSX), HDF5, GAUSS Matrix (FMT), GAUSS Dataset (DAT), Stata (DTA) and SAS (SAS7BDAT, SAS7BCAT). |
|
Writes a matrix or dataframe in memory to a dataset in a specified format. |
CSV and delimited text files#
Spreadsheets (Excel files)#
Returns the number of sheets in an Excel® spreadsheet. |
|
Returns the size (rows and columns) of a specified sheet in an Excel® spreadsheet. |
|
Gets the cell format types of a row in an Excel® spreadsheet. |
|
Builds an Excel® range string from a row/column pair. |
|
Reads from an Excel® spreadsheet into a GAUSS matrix. |
|
Reads from an Excel® spreadsheet into a GAUSS string array. |
|
Writes a GAUSS matrix, string, or string array to an Excel® spreadsheet. |
HDF 5 files#
Create a HDF5 dataset (.h5). |
|
Open a HDF5 file. |
|
Reads data from a HDF5 file (.h5) into a GAUSS matrix. |
|
Read attributes from a HDF5 file into GAUSS. |
|
Writes a GAUSS matrix to a HDF5 file. |
GAUSS Data Sets#
These are the main functions to use for loading and saving GAUSS datasets.
Loads a data set into a GAUSS dataframe. |
|
Saves matrices or dataframes to a variety of dataset types. |
The following functions use file handles which enable reading and writing partial chunks of a dataset.
Closes an open data set (.dat file). |
|
Closes all open data sets. |
|
Creates a file handle to a new, empty GAUSS data set. |
|
Opens a file handle to a GAUSS data set. |
|
Tests for end of file. |
|
Computes number of rows to read per iteration for a program that reads data from a disk file in a loop. |
|
Computes number of rows to read per iteration for a program that reads data from a disk file in a loop. |
|
Reads rows from open data set. |
|
Moves pointer to specified location in open data set. |
|
Creates a temporary file with a unique name. |
|
Returns the element size (2, 4 or 8 bytes) of data in open data set. |
|
Writes matrix to a GAUSS dataset using open file handle. |
Databases#
Database Setup#
Adds a database to the list of database connections using the driver type or a connection URL. |
|
Returns a list of available database drivers. |
|
Returns 1 if a specified database driver is available. |
|
Removes a database connection from the list of open database connections. Frees all related resources. |
Database Properties#
Returns the connection options string used for a database connection. |
|
Returns the name of the database. |
|
Returns the name of the connection’s database driver. |
|
Returns the database connection’s host name. |
|
Returns a connection’s password. |
|
Returns the default numerical precision policy for a specified database connection. |
|
Returns the database connection’s port number if it has been set. |
|
Reports whether a specified database connection is open. |
|
Reports whether a specified database connection has a valid driver. |
|
Sets database-specific options. |
|
Sets the connection’s database name to name. |
|
Sets the specified database connection’s host name. |
|
Sets the default numerical precision policy used by queries created on this database connection. |
|
Sets the database connection’s password. |
|
Sets the specified database connection’s port number. |
Database Information#
Returns the primary index for the specified table. |
|
Returns a string array populated with the names of all the fields in a specified table (or view). |
|
Returns the database’s tables, system tables and views. |
|
Returns a 1 if the database supports the specified feature. |
Database Errors#
Returns numerical information about the last error that occurred on the database. |
|
Returns text information about the last error that occurred on the database. |
|
Reports whether an error occurred while attempting to open the database connection. |
|
Returns numerical error information about the last error that occurred (if any) with the last executed query. |
|
Returns text error information about the last error that occurred (if any) with the last executed query. |
Database Connect#
Database Transaction#
Commits a transaction to the database if the driver supports transactions and a dbTransaction() has been started. |
|
Process an SQL statement and prepare a query. |
|
Executes an SQL statement and creates a query. |
|
Executes an SQL statement and creates a query for multiple rows of data in one function call. |
|
Rolls back a transaction on the database. |
|
Begins a transaction on the database. |
Query Building#
Set the placeholder placeholder to be bound to value val in the prepared statement. |
|
Returns the value for a placeholder in a query. |
|
Returns an Nx2 string array containing the placeholders and their corresponding values in a query. |
|
Executes a previously created and prepared query. |
|
Prepares a SQL query for execution. |
Query Manipulation#
Clears the result set and releases any resources held by the query. Sets the query state to inactive. |
|
Instructs the database driver that no more data will be fetched from this query until it is re-executed. |
Query Information#
Returns the number of fields in the record. |
|
Returns the object ID of the most recent inserted row if supported by the database. |
|
Returns the text of the current query being used. |
|
Reports the number of rows affected by the result’s SQL statement. |
|
Returns 1 if the query is active. |
|
Reports whether you can only scroll forward through a result set. |
|
Reports whether the current field pointed at by an active query positioned on a valid record is NULL. |
|
Reports whether the specified query is a SELECT statement. |
|
Reports whether the specified query is positioned on a valid record. |
|
Returns the size of the result (number of rows returned), or -1 if the size cannot be determined or if the database does not support reporting information about query sizes. |
|
Sets forward only mode to forward. If forward is true, only ../dbQuerySeekNext and ../dbQuerySeek with positive values, are allowed for navigating the results. |
Query Iteration#
Returns the current internal position of the query. |
|
Retrieves the record at a specified position, if available, and positions the query on the retrieved record. |
|
Retrieves the first record in the result, if available, and positions the query on the retrieved record. |
|
Retrieves the last record in the result, if available, and positions the query on the retrieved record. |
|
Retrieves the next record in the result, if available, and positions the query on the retrieved record. |
|
Retrieves the previous record in the result, if available, and positions the query on the retrieved record. |
Query Data Retrieval#
Returns the result set for the current query as a matrix. |
|
Returns the result set for the current query as a string array. |
|
Returns a single row as an Nx1 matrix where N is the column count of the SELECT statement. |
|
Returns a single row as a string vector containing the field information for the current query. |
|
Returns the value of a specified field in the current record. |
General text file manipulation#
To read and write data from CSV and delimited text files, see the earlier section.
Gets the error status of a file. |
|
Gets the error status of a file, then clears it. |
|
Flushes a file’s output buffer. |
|
Reads a line of text from a file. |
|
Reads lines of text from a file into a string array. |
|
Reads lines of text from a file into a string array without retaining newlines. |
|
Reads a line of text from a file without retaining the newline. |
|
Opens a file. |
|
Writes strings to a file. |
|
Writes strings followed by a newline to a file. |
|
Positions the file pointer in a file. |
|
Returns an error message explaining the cause of the most recent file I/O error. |
|
Gets the position of the file pointer in a file. |
|
Loads an ASCII or binary file into a string. |
|
Writes the contents of a string to a file. |