On May 7, 2:51 pm, rohit <[EMAIL PROTECTED]> wrote: > hi, > i am developing a desktop search.For the index of the files i have > developed an algorithm with which > i should be able to read and write to a line if i know its line > number. > i can read a specified line by using the module linecache > but i am struck as to how to implement writing to the n(th) line in a > file EFFICIENTLY > which means i don't want to traverse the file sequentially to reach > the n(th) line > > Please help. > Regards > Rohit
Hi, Looking through the archives, it looks like some recommend reading the file into a list and doing it that way. And if they file is too big, than use a database. See links below: http://mail.python.org/pipermail/tutor/2006-March/045571.html http://mail.python.org/pipermail/tutor/2006-March/045572.html I also found this interesting idea that explains what would be needed to accomplish this task: http://mail.python.org/pipermail/python-list/2001-April/076890.html Have fun! Mike -- http://mail.python.org/mailman/listinfo/python-list