+ 2
How to read a csv file with 3 columns of datai.e. name, ID and mark? After reading the data,how can we convert the mark as grade
assignment
3 Antworten
+ 2
A csv file contains values seperated by commas. So all you need to do is use a getline call to read a row from a csv file into a string, then replace all commas present in the row with spaces, and then read the row data (stored as a string) into your class members via istringstream or sscanf.
Then, you can convert marks to grade by calculating percentage and then using an if-else block to assign or return the respective grade.
+ 2
SQrL C++ lacks a split function unlike other languages. So, the best bet is to use stringstream. But we do have a way to split a string into iterators using regex.
+ 1
Does C++ have a string split so you can break each row into 3 parts based on where the commas are? If so, I would recommend this approach over conversion of comma to space.