Hi Guys,
How does one check the order of lines in a file?
Example file:
a b c d e f
b c d e f g
1 2 3 4 5 0
Requirements:
- All lines beginning a, must precede lines beginning b.
- There is no limit on number of lines beginning a.
- Lines beginning a, may or may not be present.
- Lines containing integers, must follow lines beginning b.
- Numeric lines must have at least two integers followed by zero.
- Failure to meet conditions must raise error.
I initially thought a rather long-winded for loop, but that failed as I am unable to index lines beyond line[0]. Also, I do not know how to define location of one line relative to the others. There is no limit on the length of these files so memory may also be an issue.
Any suggestions very welcome! Simple and readable is welcome for this confused novice!
Thanks, Seafoid.