On 04/19/2018 07:57 AM, Wolfgang Maier wrote: > On 04/19/2018 10:45 AM, Niharika Jakhar wrote: >> 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)) >> > > In addition to your immediate problem, which Steven explained already, > you will run into more issues with the posted code:
In addition to this low level advice, let me observe that whenever the term "big data" is tossed into the discussion, you want to consider whether reading it all in to Python's memory into a "simple" data structure in one go is what you want to do. You may want to look into the Pandas project (possibly after spending a little more time becoming comfortable with Python itself first): https://pandas.pydata.org/ Pandas has its own file handling code (particularly, a read_csv function) which might end up being useful. Also quite by chance, I happen to know there's an existing project to interact with the BioGRID web service, have no idea if that would be a match for any of your needs. A quick google to refind it: https://github.com/arvkevi/biogridpy _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor