I'm working on a small project and I encountered a problem.
I'm reading a file something like this (note, the original file has around 40k rows):
35 IMAGE:1679942 SAMD4 Sterile alpha motif domain Hs.98259 ATI146610
36 IMAGE:1700154 AI049531
37 IMAGE:1865232 AI269361
As you can see, there are some cells, which are containing information, and some not.
So I want that in every cell, where no information is stored, an N/A. How can I do this?
.split() does make a list without these cells. Is there a solution, how can I keep all these taps in a list i.e. line = ["36", "IMAGE:1700154", "", "", "", "AI049531", ...]
You can split at tabs (Edit Using data from comment):
data = """35\tIMAGE:1679942\tSAMD4\tSterile alpha motif domain\tHs.98259\tATI146610
36\tIMAGE:1700154\t\t\tAI049531"""
for line in data.split("\n"):
print line.split("\t")
Result:
['35', 'IMAGE:1679942', 'SAMD4', 'Sterile alpha motif domain', 'Hs.98259', 'ATI146610']
['36', 'IMAGE:1700154', '', '', 'AI049531']
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With