我在本網站和google上搜索了一些內容。但我無法理解我看到的很多代碼,我希望能從這裏找到更多的直接幫助。我只有2個學期的C + +,我有一個副項目編號喜歡爲我的老闆做。從.csv讀取數據並存入C++中的數組
他爲通話記錄生成一個csv文件,我希望能夠從日誌中檢索某些行並能夠計算和顯示數據。
林不知道我要問,但是我的繼承人代碼,我想開始獲取數據,但遇到了問題(我的編程知識也相當有限,由於缺少時間和經驗:)
#include <iostream>
#include <fstream>
#include <iomanip>
using namespace std;
int main()
{
//opens the csv file.
ifstream gwfile;
gwfile.open("log.csv");
if(!gwfile) { // file couldn't be opened
cout << "FAILED: file could not be opened" << endl << "Press enter to close.";
cin.get();
return 0;
}else
cout << "SUCCESSFULLY opened file!\n";
cout << "-------------------------------------------------------------------------------\n\n\n";
long int SIZE = 0;
char data[SIZE];
cout << "This is data SIZE:" << data[SIZE] << endl;
//in the csv im trying to only read lines that start with the voice as those are only valid data we need.
//also i would like to display the headings in teh very first line
while(!gwfile.eof()){
//This is where im trying to only accept the lines starting with "Voice"
//if(data[SIZE] == "Voice"){
for(int i=0; i!=","; i++){
cout << "This is i: " << i << endl; //testing purposes.
}
//}
// getline(gwfile, data, '');
// cout << data[0];
}
return 0;
}
確切的問題
是否有一個特別的原因,你想在C++中做到這一點? – 2012-03-11 00:40:03
我只知道C++,對我來說這似乎是一個很棒的任務。 – Nickoli 2012-03-11 01:14:46
任何其他幫助? – Nickoli 2012-03-12 20:08:32