how to read csv file

Input file:

Course Of Sales.csv
Time,Price ($),Volume,Value ($),Condition
10/10/2013 04:57:27 PM,5.81,5000,29050.00,LT XT
10/10/2013 04:48:05 PM,5.81,62728,364449.68,SX XT
10/10/2013 04:10:33 PM,.00,0,.00,

how to read the csv file with my own vector class
i already have date.h,date.cpp,time.h,time.cpp
i have no idea how to do the maintest and how to create the vector class
i need to show Date, highest price and Start time(s) of the highest share price

please anyone help me, really appreciate your help
thanks!
The file is comma delimited, so read the entire line and split it with a tokenizer.
if you share the code you have written so far, we'll be able to help you improve it or overcome the obstacles.

how to create the vector class
I assume you mean how to use the C++ built-in std::vector
example here:
http://www.cplusplus.com/reference/vector/vector/vector/
#include "date.h"
#include "time.h"
#include "stock.h"
#include "Vector.h"
#include <fstream>
#include <string>
#include <iostream>

using std::cout;
using std::endl;
using std::cin;

int main()
{
date date;
time24 time;
double price;
double volume;
double value;
double max=0;
string condition;
char menu = ' ';

ifstream in;
ofstream out;

in.open("Course_of_sales.txt");
out.open("bbb.txt");

out<< fixed << showpoint;
cout << "Processing Data" << endl;
do {
cout << "The Menu Options available are as follows - "
"\n1: Date, highest price and Start time(s) of the highest share price"
"\n2: Date, Lowest price, Start time(s) of the lowest share price"
"\n3: output.csv"
"\n4: Exit the program"
"\n\nEnter option: ";
cin >> menu;
cout << endl;

switch (menu)
{
case '1':
cout<<"Date:"<<date<<endl;
cout<<"Highest Price:"<<priceMAX<<endl;
cout<<"Start time(s):"<<endl<<time<<endl;
break;
case '2':
cout<<"Date:"<<date<<endl;
cout<<"Lowest Price:"<<priceMIN<<endl;
cout<<"Start time(s):"<<endl<<time<<endl;
break;

case'3':
break;

case'4':
cout << "Exit, thank you" << endl;
break;

default:
cout << "Sorry, invalid option" << endl;
}
}
while (menu != '4');


in>>date>>time>>price>>volume>>value>>condition;

while (!in.eof())
{
if(price>max)
price=max;
}

in.close();
out.close();



system("PAUSE");
return 0;
};



sorry my main is really messy, i havent do the priceMAX and priceMIN
i dont have any idea how to print read the csv and print the highest price with this format
Menu option 1:
Date:<the transaction date>
Highest price:<the highest price>
Start time(s):
<time when the highest price occured>

how to search the highest price and show the start time and date, do i need to make an array?
Topic archived. No new replies allowed.