0

I have a csv file that has 500 rows and 2 columns, and this file is full of doubles. I want to read this in to c++, and access the values in the array and use them to do calculations. I have tried reading them in as strings then converting stringstream, getline, and lineStream, but the numbers that print out are nowhere close to the ones in the original file. I just want to know if there's a fairly straightforward way to do this that I am just not realizing. I also wouldn't mind a good explanation on what getline() and lineStream() do, as I could be using these incorrectly. Thanks!

  • 2
    ***I have tried reading them in as strings then converting stringstream, getline, and lineStream, but the numbers that print out are nowhere close to the ones in the original file.*** You need to show your minimal code as text for any hope of someone to help fix your code. Most users won't just write you a program. [mcve] – drescherjm Feb 24 '20 at 21:35
  • BTW, the approach you mention ***reading them in as strings then converting stringstream, getline, and lineStream*** is reasonable. You most likely have one or more bugs in your implementation. – drescherjm Feb 24 '20 at 21:37
  • ***I also wouldn't mind a good explanation on what getline() and lineStream() do*** providing a tutorial is off topic at StackOverflow. – drescherjm Feb 24 '20 at 21:41
  • Are the numbers comma separated or space separated? Hint: use `std::getline` and `std::istringstream`. – Thomas Matthews Feb 24 '20 at 21:54

0 Answers0