reading CSV file into Array

Good Day All Been programming in C now learning C++.Can any body advise me to scan a CSV file with "EM305","Front Door Entrance Reader","7h30", "16H30","S2010","Front Door Entrance Reader","7h30","15h30" into an array so i can do calculations for every line. How can i detect if the end of line is reached "16h30" is my last record before the next line should start.

Can anybody assist.
Please post your code showing what you've tried.

Also please post your code inside code tags to preserve formatting.

Post an actual example of the file showing several lines of data. You mention lines but all that's in that post is one line with 8 elements. Do all lines have this format? Does the format vary?

Do you know how to open a file, test to see it was successfully open, and if so how to read the data in the file?

Show what code you've written to do this, along with a sample of your file's data PROPERLY formatted.

For example:

my_source.cpp
1
2
3
4
5
6
7
8
9
10
#include <iostream>

// what would I include to work with files?

int main()
{
   std::cout << "I can read a file!\n";

   // code to read a file and deal with the data inside
}

my_data.txt
"EM305","Front Door Entrance Reader","7h30","16H30","S2010","Front Door Entrance Reader","7h30","15h30"

or maybe
"EM305","Front Door Entrance Reader","7h30","16H30",
"S2010","Front Door Entrance Reader","7h30","15h30"


PLEASE learn to use code tags, they make reading and commenting on source code MUCH easier.

http://www.cplusplus.com/articles/jEywvCM9/
http://www.cplusplus.com/articles/z13hAqkS/

HINT: you can edit your post and add code tags.

Some formatting & indentation would not hurt either

Topic archived. No new replies allowed.