I'm trying to read a file in Python that looks something like this:
hello\t\tsecondhello\n
this\t\tsecondthis\n
is\t\tsecondis\n
data\t\tseconddata\n
I'm only interested in the second piece of information for each line, so I'm trying to get rid of those two tabs and the new lines. I tried this:
documents = open("data.txt", "r").readlines()
for line in documents:
splitted = line.strip().split("\t")
print(splitted)
But this only gives me list objects that look like this:
['hello\t\tsecondhello']
I've also looked at this accepted answer but it gives me the same only that the new lines are kept as well: splitting a string based on tab in the file
EDIT: found the error, it was false formatting in the input file. still, thanks for your help, people