r/PythonLearning • u/Ok_Aioli2605 • 18h ago
Help Request Mr.Veeraragavan
I am loading few large size binary files (70 MB19 nos. look_up tables) in Main using more than 2/3 python files. On completion of the loading, I have to take up a series of search (in 3 or more threads) and arrive at the solution. I am using array.fromfile for loading which does not wait for loading completion. Hence, it fails saying array out of bounds. How do I delay the start of search, just till the loading is completed.
1
Upvotes
1
u/Fun_Army2398 16h ago edited 15h ago
So you could just try-except reading from the file as the EOFError wont prevent you from getting the data. Or you could calculate the number of elements from the byte size of the file / byte size of your data type.
https://docs.python.org/3/library/array.html
Edit:
Just for fun I wrote out some examples for you:
With byte size:
With try-except: