읽기 .CSV 과학적 표기법은 데이터의 예는 다음과 같습니다내가 여기이 .csv 파일을 읽으려고하고 있어요
1.33286E+12 0 -20.790001 -4.49 -0.762739 -3.364226 -8.962189
1.33286E+12 0 -21.059999 -4.46 -0.721878 -3.255263 -8.989429
문제는 Excel에서 첫 번째 열에 행 1과 2를 함께 제출할 셀의 숫자는 1.33286E + 12로 표시되며 셀을 클릭하면 1332856031313과 1332856031328이지만 프로그램은 1.33286E + 12로 읽음을 나타내지 만 전체 숫자는 1332856031313과 1332856031328이 필요합니다.
코드 :
inputfile.open(word1.c_str());
while (getline (inputfile, line)) //while line reads good
{
istringstream linestream(line); //allows manipulation of string
string str;
while (getline (linestream, item, ',')) //extract character and store in item until ','
{
char * cstr, *p;
cstr = new char [item.size()+1];
strcpy(cstr, item.c_str());
p = strtok(cstr, " ");
while (p!=NULL) //while not at the end loop
{ // double e = atof(p); // coverts p to double
value++;
if(value == 1)
{ double e = atof(p); // coverts p to double
if(m ==1)
cout << time[0]<<"\n";
ostringstream str1;
str1 << e;
str = str1.str();
string str2;
str2.append(str.begin(), str.end());
const char * convert = str2.c_str();
e = atof(convert);
time[m] = e*0.001;
m++;
//if(m >=192542)
//cout << time[m-1]<<"\n";
}
p = strtok(NULL, " ");
}
delete[] cstr; //delete cstr to free up space.
}
count ++;
value = 0;
}
inputfile.close();
문제는 독자가 아니며 작가에게 있습니다. 완전 정확도로 값을 출력하려면 CSV 생성기 (Excel, 아마도?)를 가져와야합니다. – Rook