//first i read a csv file , then do some data process and analysis to build a physics model to test //some function. The following is some of my C++ code.
static unordered_map<double, TrackData> ReadCsvFile(const string&
filePath) {...
string line;
getline(file, line);
while (getline(file, line)) {
istringstream iss(line);
vector<string> values;
string value;
while (getline(iss, value, ';')) {
values.push_back(value);
}...
trackData.TrackID = stod(values[0]);
trackData.Type = values[1];
trackData.TrackWidth = stod(values[2]);
trackData.TrackWidthDisplacement = stod(values[3]);
trackData.TrackLength = stod(values[4]);
trackData.TrackLengthDisplacement = stod(values[5]);`
//////////////////////////////////////////
and the data in the csv file is shown below.
1; Car; 2.0000; 0.0000; 5.0000; 0.0000; “Gate 14”; 73.200000; “Gate 15”; 74.233333; 7.71; 26.846970;…
but the output is to be “Invalid argument: invalid stod argument in line:…..”
hope someone could give some tips , thanks a lot and appreciate for your reading
黃浩哲 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.