where does this string come from - is it a file
if it comes from a file, you can use csv module, if it's just a string - you can use io.StringIO and then csv module
if it comes from a file, you can use csv module, if it's just a string - you can use io.StringIO and then csv module
spam = 'asdas asdd sd a2123 3234 "test asd" asda' import io import csv eggs = io.StringIO(spam) rdr = csv.reader(eggs, delimiter=' ') for line in rdr: print(line)
Output:['asdas', 'asdd', 'sd', 'a2123', '3234', 'test asd', 'asda']
you can further process the list to get desired output
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs