[Tutor] File handling Tab separated files

Niharika Jakhar niharika1883 at gmail.com
Thu Apr 19 04:45:07 EDT 2018


Hi
I want to store a file from BioGRID database (tab separated file, big data)
into a data structure(I prefer lists, please let me know if another would
be better) and I am trying to print the objects.
Here’s my code:
class BioGRIDReader:
    def __init__(self, filename):
            with open('filename', 'r') as file_:
            read_data = f.read()
            for i in file_ :
                read_data = (i.split('\t'))
                return (objects[:100])

a = BioGRIDReader
print (a.__init__(test_biogrid.txt))




Here's what the terminal says:
Traceback (most recent call last):
  File "./BioGRIDReader.py", line 23, in <module>
    print (a.__init__(test_biogrid.txt))
NameError: name 'test_biogrid' is not defined

The file named test_biogrid.txt do exist in the same folder as this program.

I am unable to go further with this code. Kindly help me out.


Thanks and regards
NIHARIKA


More information about the Tutor mailing list