wie bekomm ich die größe einer datei, die ich dann in file.read() verwenden kann?
ich verwende eine Beispieldatei in der nur "Hallo, na wie gehts?" steht.
Damit funktioniert alles:
Code: Alles auswählen
#!/usr/bin/python
# -*- coding: utf-8 -*-
import time
import numpy as np
import csv
import os
desktopFile = os.path.expanduser("~\Desktop")
path_grund = desktopFile+'\Handy-Datenbank'
path_folder = path_grund+'\\Beispiel.001'
filesize = os.stat(path_folder).st_size
print filesize
f = open(path_folder, 'rb')
def count(f):
while 1:
block = f.read(filesize)
if not block:
break
yield block.split(";")
linecount = count(f)
print next(linecount)
Damit funktioniert es nicht
ich bekomme ein Exception:
Code: Alles auswählen
Message File Name Line Position
Traceback
<module> C:\Users\DMD-OL\Desktop\Handy-Datenbank\Einlesen.py 25
count C:\Users\DMD-OL\Desktop\Handy-Datenbank\Einlesen.py 19
exceptions.MemoryError
Was ist da falsch?