diff --git a/BioFVM/BioFVM_microenvironment.cpp b/BioFVM/BioFVM_microenvironment.cpp index fb2e535ff..84c975ed6 100644 --- a/BioFVM/BioFVM_microenvironment.cpp +++ b/BioFVM/BioFVM_microenvironment.cpp @@ -47,6 +47,7 @@ */ #include "BioFVM_microenvironment.h" +#include "BioFVM_utilities.h" #include "BioFVM_solvers.h" #include "BioFVM_vector.h" #include @@ -1467,6 +1468,7 @@ void load_initial_conditions_from_csv(std::string filename) // determine if header row exists std::string line; std::getline( file , line ); + trim_cr(line); char c = line.c_str()[0]; std::vector substrate_indices; bool header_provided = false; @@ -1515,6 +1517,7 @@ void load_initial_conditions_from_csv(std::string filename) file.close(); std::ifstream file(filename, std::ios::in); std::getline(file, line); + trim_cr(line); } std::cout << "Loading substrate initial conditions from CSV file " << filename << " ... " << std::endl; @@ -1522,6 +1525,7 @@ void load_initial_conditions_from_csv(std::string filename) while (std::getline(file, line)) { + trim_cr(line); get_row_from_substrate_initial_condition_csv(voxel_set, line, substrate_indices, header_provided); } diff --git a/BioFVM/BioFVM_utilities.h b/BioFVM/BioFVM_utilities.h index c5162d88a..fbaea7ace 100644 --- a/BioFVM/BioFVM_utilities.h +++ b/BioFVM/BioFVM_utilities.h @@ -78,9 +78,12 @@ void seed_random( void ); double uniform_random( void ); double compute_mean( std::vector& values ); -double compute_variance( std::vector& values, double mean ); -double compute_variance( std::vector& values ); - +double compute_variance( std::vector& values, double mean ); +double compute_variance( std::vector& values ); + +inline void trim_cr( std::string& line ) +{ if (!line.empty() && line.back() == '\r') { line.pop_back(); } } + }; #endif diff --git a/core/PhysiCell_rules.cpp b/core/PhysiCell_rules.cpp index 3b73a38a3..b7442399d 100644 --- a/core/PhysiCell_rules.cpp +++ b/core/PhysiCell_rules.cpp @@ -1535,8 +1535,9 @@ void parse_csv_rules_v0( std::string filename ) while( fs.eof() == false ) { - std::string line; - std::getline( fs , line, '\n'); + std::string line; + std::getline( fs , line, '\n'); + trim_cr(line); if( line.size() > 0 ) { parse_csv_rule_v0(line); } } @@ -1671,8 +1672,9 @@ void parse_csv_rules_v1( std::string filename ) while( fs.eof() == false ) { - std::string line; - std::getline( fs , line, '\n'); + std::string line; + std::getline( fs , line, '\n'); + trim_cr(line); if( line.size() > 0 ) { parse_csv_rule_v1(line); } } @@ -1804,8 +1806,9 @@ void parse_csv_rules_v3( std::string filename ) while( fs.eof() == false ) { - std::string line; - std::getline( fs , line, '\n'); + std::string line; + std::getline( fs , line, '\n'); + trim_cr(line); if( line.size() > 0 ) { parse_csv_rule_v3(line); } } diff --git a/modules/PhysiCell_geometry.cpp b/modules/PhysiCell_geometry.cpp index a995422ea..0cd02c106 100644 --- a/modules/PhysiCell_geometry.cpp +++ b/modules/PhysiCell_geometry.cpp @@ -308,6 +308,7 @@ void load_cells_csv_v1( std::string filename ) std::string line; while (std::getline(file, line)) { + trim_cr(line); std::vector data; csv_to_vector( line.c_str() , data ); @@ -840,6 +841,7 @@ void load_cells_csv_v2( std::string filename ) std::string line; std::getline( file , line ); + trim_cr(line); // tokenize the labels @@ -848,7 +850,10 @@ void load_cells_csv_v2( std::string filename ) // process all remaining lines while (std::getline(file, line)) - { process_csv_v2_line(line,labels); } + { + trim_cr(line); + process_csv_v2_line(line,labels); + } // close the file @@ -871,6 +876,7 @@ void load_cells_csv( std::string filename ) // determine version std::string line; std::getline( file , line ); + trim_cr(line); char c = line.c_str()[0]; file.close();