Separate file lines into tokens - Python

Asked

Viewed 626 times

2

I want to read the line of a file and store each word or information in a vector position. Ex: "18-10-2015 00092 65534". line[1] = 18-10-2015 line[2] = 00092 line[3] = 65534 OBS: tab between strings

  • 2

    First show what you have tried to do, according to what are the rules for tokenization? does not allow someone to answer without knowing what constitutes an "information" in its context.

2 answers

1

To separate a string using spaces as delimiters, you use the method .split():

>>> "18-10-2015 00092 65534".split()
>>> ["18-10-2015", "00092", "65534"]

0

Browser other questions tagged

You are not signed in. Login or sign up in order to post.