python - How to extract data from .txt file that is separated by varying space size? -


i trying extract data (date , time) .txt file, raise 1 second , compare next piece of data can see if date , time continuous.

for example:

15  6 19  9 12 59.0000000   ... other stuff...   15  6 19  9 13  0.0000000 

the problem number of spaces between digits varies (one space if data on right 2 digits, 2 spaces if data on right 1 digit).

how can extract dates, increment 1 second , compare them next date in text without having check every space variation?

you can use string.split() , splits string varying spaces .

and example -

>>> s = "hello  bye          test" >>> s 'hello  bye          test' >>> s.split() ['hello', 'bye', 'test'] 

Comments

Popular posts from this blog

timeout - Handshake_timeout on RabbitMQ using python and pika from remote vm -

gcc - MinGW's ld cannot perform PE operations on non PE output file -

c# - Search and Add Comment with OpenXML for Word -