I am a bigginer in python and even programming. I want to use python in my thesis for reading and writing large size data. I have a little sample of code which access which runs over the lines and reads each element on a line.
def get_site_only(pat):
newpat = ""
for c in pat:
if c.isalpha():
newpat +=c
return newpat
def read_rebase(filename):
enz_dict={}
infh= open("rebase.dat")
for line in infh.xreadlines():
fields = line.split()
name = line.split()[0]
pat = line.split()[2]
enz_dict[name] = get_site_only(pat)
infh.close()
return enz_dict
print read_rebase("rebase.dat")
I get the following error message:
Traceback (most recent call last):
File "D:\Downloads\Python2\trial3.py", line 20, in <module>
print read_rebase("rebase.dat")
File "D:\Downloads\Python2\trial3.py", line 13, in read_rebase
name = line.split()[0]
IndexError: list index out of range
would you please help me with this problem
chebude