Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8104767
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T23:58:26+00:00 2026-06-05T23:58:26+00:00

I am trying to read this .csv file and here is an example of

  • 0

I am trying to read this .csv file and here is an example of the data:

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

The problem is with the first column row 1 and 2. In the excel file it says the numbers in the cells are displayed as 1.33286E+12 and when you click on the cell it says they are 1332856031313 and 1332856031328 but the program is reading them as 1.33286E+12 but I need the whole number 1332856031313 and 1332856031328.

The code:

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();
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T23:58:28+00:00Added an answer on June 5, 2026 at 11:58 pm

    If the number 1332856031313 is being serialised as 1.33286E+12, there is no way to get it back in the deserialisation process. Information in the form of those 6 extra significant digits is gone forever. You need to make sure that when the CSV file is generated, it is saved at full precision. I don’t know how you might do this with Excel.

    Also, your use of atof and const char* isn’t very C++-esque. Consider using code like

    double a, b, c, d;
    linestream >> a >> b >> c >> d;
    

    instead.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to read the data from a file that I've saved. This code
I am trying to read from a csv file and insert the data into
Im trying to read and write to/from the same file, is this possible? Here
I'm trying to read data from a.csv file to ouput it on a webpage
I am trying to read in a CSV file that looks like this: ruby,2,100
I am trying to read this file I created as sample made up from
Does play automatically cache data? I'm trying to read this code that someone else
I have this error when I am trying to read the file: Exception in
To simplify, I'm trying to read the content of a CSV-file using the ifstream
I have a csv file that I am trying to read in R, for

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.