Bir dosyayı okuyan bir program oluşturuyorum ve dosyanın ilk satırı boş değilse, sonraki dört satırı okur. Hesaplamalar bu satırlarda yapılır ve bir sonraki satır okunur. Bu satır boş değilse devam eder. Ancak, bu hatayı alıyorum:
ValueError: invalid literal for int() with base 10: ''.
İlk satırı okuyor ama tamsayıya dönüştüremiyor.
Bu sorunu gidermek için ne yapabilirim?
Kod:
file_to_read = raw_input("Enter file name of tests (empty string to end program):")
try:
infile = open(file_to_read, 'r')
while file_to_read != " ":
file_to_write = raw_input("Enter output file name (.csv will be appended to it):")
file_to_write = file_to_write + ".csv"
outfile = open(file_to_write, "w")
readings = (infile.readline())
print readings
while readings != 0:
global count
readings = int(readings)
minimum = (infile.readline())
maximum = (infile.readline())


with open(file_to_read, 'r') as infile:Orada kullanmayı düşünmelisiniz .