Separate rows of files in tokens - Python

1

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

    
asked by anonymous 14.03.2016 / 16:52

2 answers

1

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

>>> "18-10-2015 00092 65534".split()
>>> ["18-10-2015", "00092", "65534"]
    
14.03.2016 / 17:09
0

Use the string.split () method, link

“split this string”.split(‘ ‘)
[‘split’, ‘this’, ‘string’]
>>> “split,this,string”.split(‘,’)
[‘split’, ‘this’, ‘string’]
    
14.03.2016 / 17:10