1

i have a text file in an external HD E:

my_file = "E:\\myfolder\\myfile.txt"

lines_len = 0
for p in open(my_file , "r"):
   lines_len +=1

i wish to read all line. When the file read a certain amount of line i get this message

Traceback (most recent call last):
  File "<input>", line 2, in <module>
IOError: [Errno 13] Permission denied
Gianni Spear
  • 7,033
  • 22
  • 82
  • 131
  • What you are doing is more efficient but since you mention it fails in the middle you can try to read the whole file at once and see. for p in list(open(my_file,"r")): line_len +=1 – user3885927 Sep 23 '14 at 18:30
  • OK, then I would suggest to copy the file to your drive and see if you still get the error. That will give a clue if there are any problems with the external drive. – user3885927 Sep 23 '14 at 18:35
  • 1
    This might be a large-file issue; are you using 32bit Python? Do you know at what offset (number of bytes in the file) the error happen? What is the disk's filesystem? – remram Sep 25 '14 at 04:09

0 Answers0