Tworzę program, który czyta plik i jeśli pierwszy wiersz pliku nie jest pusty, odczytuje kolejne cztery wiersze. Obliczenia są wykonywane na tych liniach, a następnie odczytywany jest następny wiersz. Jeśli ten wiersz nie jest pusty, kontynuuje. Jednak pojawia się ten błąd:
ValueError: invalid literal for int() with base 10: ''.
Czyta pierwszy wiersz, ale nie może go przekonwertować na liczbę całkowitą.
Co mogę zrobić, aby rozwiązać ten problem?
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:tam.