9bool file_IO::csv_import(
string file_address,
v_container &table){
18 file.open(file_address);
23 if(c ==
'\n' || c ==
','){
26 table.
insertData(stod(cell), row_index, col_index);
29 catch(
const std::invalid_argument& e){
30 std::cerr <<
"FAILED TO READ CORRUPTED FILE "<< e.what() << endl;
33 catch(
const std::out_of_range& e){
34 std::cerr <<
"VERY LARGE OR VERY SMALL values IN THE FILE "<< e.what() << endl;
60bool file_IO::csv_export(
string file_address,
v_container &table){
62 outputFile << std::setprecision(10);
63 outputFile.open(file_address);
64 if(!outputFile.is_open()){
65 cout <<
"unexpected error" << endl;
69 unsigned int col_index;
70 unsigned int row_index;
71 for(row_index = 0; row_index < table.
get_row_num(); row_index++){
72 for(col_index = 0; col_index < (table.
get_col_num() - 1); col_index++){
73 outputFile << table.
getData(row_index,col_index) <<
',';
75 outputFile << table.
getData(row_index,col_index) << endl;
88 return csv_import(file_address, data);
100 return csv_export(file_address, data);
HELD_DATA getData(int row, int col) const
return the data at some address
void insertData(HELD_DATA d, unsigned int row, unsigned int col)
inserts a value to a cell of dataTable instance with that address
unsigned int get_col_num()
unsigned int get_row_num()
contains a basic flexible and extensible interface for file imports and exports operations other stru...
bool data_import(string file_address, dataTable< double > &data, int type)
a function that imports files with supported file formats
bool data_export(string file_address, dataTable< double > &data, int type)