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
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
To separate a string using spaces as delimiters, you use the .split()
method:
>>> "18-10-2015 00092 65534".split()
>>> ["18-10-2015", "00092", "65534"]
Use the string.split () method, link
“split this string”.split(‘ ‘)
[‘split’, ‘this’, ‘string’]
>>> “split,this,string”.split(‘,’)
[‘split’, ‘this’, ‘string’]