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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T22:30:55+00:00 2026-05-26T22:30:55+00:00

I have a file that is organized into columns, with data that needs to

  • 0

I have a file that is organized into columns, with data that needs to be stored in a vector of a type of class to store each of the data columns, I would suppose.

The data looks like:

ATOM      1  N   PRO     1     -38.396  -1.525   2.011 -0.18 14.01
ATOM      2  CA  PRO     1     -36.931  -1.372   2.090  0.08 13.02
ATOM      3  C   PRO     1     -36.353  -0.411   1.059  0.35 12.01
ATOM      4  O   PRO     1     -36.988  -0.061   0.086 -0.37 16.00
ATOM      5  CB  PRO     1     -36.368  -2.749   1.735  0.03 14.03
ATOM      6  CG  PRO     1     -37.417  -3.202   0.763  0.01 14.03
ATOM      7  CD  PRO     1     -38.692  -2.893   1.489  0.08 14.03

There are also some redundant columns in the beginning that I do not want, how can I select data as needed.
Can someone direct me in the correct direction?

  • 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-05-26T22:30:55+00:00Added an answer on May 26, 2026 at 10:30 pm

    Just read the data in, and ignore the values you don’t care about:

    std::string c1, c3, c4;
    int c2, c5;
    double c6, c7, c8, c9, c10;
    
    if (!(input_stream >> c1 >> c2 >> c3 >> c4 >> c5 >> c6 >> c7 >> c8 >> c9 >> c10))
    {
        // error
    }
    

    If you want to make sure you’re only reading data from a single line, first use getline to put the line into a string, then use an istringstream as your input stream. You need to have a way to differentiate valid data lines from non data lines. Is it safe to assume that every valid data line begins with “ATOM”, and also that every line that begins with “ATOM” is in fact a valid data line? If so, you can use that to determine if the line is data:

    for (std::string line; std::getline(file_stream, line); )
    {
        std::string c1, c3, c4;
        int c2, c5;
        double c6, c7, c8, c9, c10;
    
        std::istringstream iss(line);
    
        iss >> c1;
        if (c1 == "ATOM")
        {
            if (!(iss >> c2 >> c3 >> c4 >> c5 >> c6 >> c7 >> c8 >> c9 >> c10))
            {
                // error
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a file that lists filenames, each on it's own line, and I
I have a file that has one entry per line. Each line has the
I have data that is organized in panels like this (see below for output
So, I have a text file that is organized like this <username>:<fullname>:<usergroups> I need
I have a PHP script that processes file uploads. The script tries to organise
I have a file that I want to include in Python but the included
We have a file that has a 64 bit integer as a string in
I have a file that apparently contains some sort of dump of a keep-alive
I have a file that contains a mish-mash of cities, states, and zip codes.
I have a file that I can get to with the UNC \mypath\myfile. I

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.