1.4.0
CCC
 
CSV.hpp File Reference
#include "Basic/VectorNumT.hpp"
#include "Basic/VectorT.hpp"
#include "geoslib_define.h"
#include "gstlearn_export.hpp"

Functions

GSTLEARN_EXPORT int csv_manage (const char *filename, const CSVformat &csv, int mode, int nitem, bool flagInteger=false, bool verbose=false)
 
GSTLEARN_EXPORT void csv_print_double (double value)
 
GSTLEARN_EXPORT Dbdb_read_csv (const char *file_name, const CSVformat &csvfmt, int verbose=0, int ncol_max=-1, int nrow_max=-1, bool flagAddSampleRank=false)
 
GSTLEARN_EXPORT int db_write_csv (Db *db, const char *filename, const CSVformat &csv, int flag_allcol=1, int flag_coor=1, bool flagInteger=false)
 
GSTLEARN_EXPORT int csv_table_read (const String &filename, const CSVformat &csvfmt, int verbose, int ncol_max, int nrow_max, int *ncol_arg, int *nrow_arg, VectorString &names, VectorDouble &tab)
 

Function Documentation

◆ csv_manage()

GSTLEARN_EXPORT int csv_manage ( const char *  filename,
const CSVformat csv,
int  mode,
int  nitem,
bool  flagInteger,
bool  verbose 
)

Manage the Utility to write into a CSV file

Returns
Error return code
Parameters
[in]filenameName of the CSV file
[in]csvCSVFormat description
[in]mode1 for opening File; -1 for closing File
[in]nitemNumber of items per line
[in]flagIntegertrue if the numerical values must be printed as integer
[in]verboseVerbose flag
Remarks
: This procedure manages an internal structure (declared as static)
: When opened, you can use csv_print_string() or csv_print_double()
: in order to store items in the file
: Do not forget to use csv_manage(-1,...) to close the file

◆ csv_print_double()

GSTLEARN_EXPORT void csv_print_double ( double  value)

Write a DOUBLE element into the (opened) CSV file

Parameters
[in]valueReal value to be written
Remarks
: This function uses CSV_ENCODING static structure
: which must have been initiated beforehand

◆ csv_table_read()

GSTLEARN_EXPORT int csv_table_read ( const String filename,
const CSVformat csvfmt,
int  verbose,
int  ncol_max,
int  nrow_max,
int *  ncol_arg,
int *  nrow_arg,
VectorString names,
VectorDouble tab 
)

Read the Data frame from a CSV file. Reserved for numerical data frame.

Returns
Error return code
Parameters
[in]filenameName of the CSV file
[in]csvfmtCSVformat structure
[in]verbose1 for a verbose output; 0 otherwise
[in]ncol_maxMaximum number of columns (or -1)
[in]nrow_maxMaximum number of rows (or -1)
[out]ncol_argNumber of columns
[out]nrow_argNumber of rows
[out]namesArray containing the variable names
[out]tabArray of values
Remarks
The returned array 'tab' is organized by sample

◆ db_read_csv()

GSTLEARN_EXPORT Db* db_read_csv ( const char *  file_name,
const CSVformat csvfmt,
int  verbose,
int  ncol_max,
int  nrow_max,
bool  flagAddSampleRank 
)

Read a CSV file and load the results into a Db

Returns
Pointer to the Db descriptor
Parameters
[in]file_nameName of the ASCII file
[in]verboseVerbose option if the file cannot be opened
[in]csvfmtCSVformat structure
[in]ncol_maxMaximum number of columns (or -1)
[in]nrow_maxMaximum number of rows (or -1)
[in]flagAddSampleRankTrue To add the rank number

◆ db_write_csv()

GSTLEARN_EXPORT int db_write_csv ( Db db,
const char *  filename,
const CSVformat csvfmt,
int  flag_allcol,
int  flag_coor,
bool  flagInteger 
)

Write the Data frame into a CSV file. Reserved for numerical data frame.

Returns
Error return code
Parameters
[in]dbName of the Db
[in]filenameName of the CSV file
[in]csvfmtCSVformat structure
[in]flag_allcol1 if all the columns available must be dumped out
[in]flag_coor1 if the coordinates must be dumped out
[in]flagIntegertrue if the numerical values must be printed as integer
Remarks
: This procedure dumps the Z-variables and optionally the X-variables