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 7744529
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T09:47:22+00:00 2026-06-01T09:47:22+00:00

I have a text file where data is stored as columns. How do I

  • 0

I have a text file where data is stored as columns. How do I extract each column in to an array?

eg: a b c d

10 11 12 13

 14 15 16 17

I want four arrays as, a = {10,14}, b = {11,15} c = {12,16} d = {13,17}

Below is what I have done so far to add them in to a single array:

CArray <double,double> *data = new CArray <double,double>();

CString strLine;

TRY

{ 
  CStdioFile file(m_fileName, CFile::modeRead); 

  while(file.ReadString(strLine)) {
      CArray <double,double> arrayValues;
      splitString(strLine,arrayValues);

      for (int i=0; i< arrayValues.GetSize()-1;i++){
        //  Temp_data[i] = arrayValues.ElementAt(i);
          data->Add(arrayValues.ElementAt(i));
      }
  }
} 
CATCH_ALL(e) 
{ 
  e->ReportError(); // shows what's going wrong 
} 
END_CATCH_ALL 


void splitString(CString S, CArray<double,double>& arrayValues){

CString sep = _T(" ");
int start = 0;
CString aux = S.Tokenize(sep, start);
arrayValues.Add(_tstof(aux));
while(start != -1){
      aux = S.Tokenize(sep, start);
      arrayValues.Add(_tstof(aux));
    
}

}

Thanks.

  • 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-01T09:47:23+00:00Added an answer on June 1, 2026 at 9:47 am

    Since you havent tried anything till i will give some suggestions to you.

    first take the line into a string and split it and then store all the values in an array.
    so at the end you will have total lines of arrays.

    now use the indexes and store them in different column array based upon the indexes like :
    all the elements in the arrays with similar index will be stored in array colN.

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

Sidebar

Related Questions

I have a text file with tab delimited data spread across 16 columns. I
I am using a text file that stores 3 columns of data, each having
I have stored values retrieved from a text file into an array. Now am
I have Text file that contains data separated with a comma , . How
I have a text file containing the data in following format 12345 Abdt3 hy45d
I have a text file which contains data seperated by '|'. I need to
Currently I have a a text file with data at the first row is
I have a giant text file (about 1,5 gigabyte) with xml data in it.
We have some C# code that reads data from a text file using a
I have a method that reads data from a comma separated text file and

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.