I have a file below. Some have a name as input, there were a few with middle name. How should i store the names?
For the first line i can use a dummy line to store them but for the name what should i do?
1 2 3 4
Name Age Subject1 Subject2 Subject3
John 13 55 55 55
John Terry 15 55 55 55
John X Terry 13 55 55 55
Depending on the format of the file, you might be able to make certain guarantees.
- Is a number allowed to be a last name? Can a suffix like "3" (maybe meaning "the third") happen? If not, then parse each word, and if that word is a number, then you know the name is over, and the age has begun.
- Is there guaranteed to be a constant number of characters (including spaces) between the start of the line and the first number character (e.g. 14 as your example has)? If so, you can just read in the first 14 characters, and then strip trailing spaces from the string.