I want to open my file.txt and split all data from this file.
Here is my file.txt:
some_data1 some_data2 some_data3 some_data4 some_data5
and here is my python code:
>>>file_txt = open("file.txt", 'r')
>>>data = file_txt.read()
>>>data_list = data.split(' ')
>>>print data
some_data1 some_data2 some_data3 some_data4 some_data5
>>>print data_list
['\xef\xbb\xbfsome_data1', 'some_data1', "some_data1", 'some_data1', 'some_data1\n']
As you can see here, when I print my data_list it adds to my list this: \xef\xbb\xbf and this: \n. What are these and how can I clean my list from them.
Thanks.
str.splitit will split on all kinds of whitespace (in any combination) and as a side effect, get rid of the newline at the end of your single line file.