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?
Just read the data in, and ignore the values you don’t care about:
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: