I have a txt file which has the following format
34432 2008-05-30 10:24:36.761334000
34433 2008-05-30 10:50:23.063773000
34439 2008-05-30 12:49:40.909249000
34443 2008-05-30 15:10:22.674575000
first is an integer. then i have the year as u can see, month, day, hour, minutes, and seconds, all in int except for sec which is double.
Now what I want to do is read each line by line. I know I can't just take them as the variables that i want immediately(like take the hour right away), but i need to take it as a string of chars and then work with it.
Now the problem is that as you can see that the variables are not separated by the same character. Between the first and the second is a 'space', and the next three is '-' and then a ':'.
The files are ordered following the first variable '30508'. I only want to look for a specific value and recover the time for that value.
Any advice on how to do this?
If you know that every line in your file will follow the same format as that, you can just read them into appropriate variables. The first ant int, and the second and third a std::string. From there, manipulate the strings until you get the results you want.
EDIT* On the other hand, you could take the whole line as a string, sperate the string into three sub strings, and then convert/manipulate from there.
Just as I thought. I know that the first 5 places will always be the same variable(it's always a 5 digist integer) same for the other variables...
The problem, it's been ages since I did this kind of work. I am used more to work interpreted C++(ROOT), and doing stuff that doesn't involve other types of files and only numerical calculations.
Anyway thx, I think I will go fresh up on my string and my chars for this.