How to read integer values from csv file

Hello,
I read one csv file in which it contains different types of data like string, integer etc.I want to fetch only integer data from that file and store in vector.Below i copy some code that read line from file,store in vector.I tried to convert string to integer or double and do some operations on it as i know that string values,but how to identify only integer values and store that in vector?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include<iostream>
#include<vector>
#include<string>
#include<fstream>
#include<sstream>
#include<iterator>
#include<algorithm>
using namespace std;

int main() 
{
	string line;
	int cnt=0,val1,val2;
	
	vector<string> vf;
	
	ifstream in("TestValues.csv");
	ofstream out("result.csv");

	while(getline(in,line,','))
	{
		vf.push_back(line);
	}	
	
	for(int i=0;i<vf.size();i++)
	{	
		val1=atoi(vf[i].c_str());
		out<<val1;
	}	

	in.close();
	out.close();
	system("pause");

	return 0;
}

input file like
1
2
3
Employee Code:	121A	Employee Name :	David	
Date		InTime	OutTime	Shift	Total Duration	Status
01-Apr-13	9:59	19:53	FS	  9:53	         Present 
That input file seems is nearly impossible to read without some heuristic.

The problem is the format may be inconsistent. It isn't clear what a field is, or how they're separated. You need a single separating character, a tab or comma. And data should appear as rows.
Topic archived. No new replies allowed.