मैं एक प्रोग्राम बना रहा हूं जो एक फाइल को पढ़ता है और अगर फाइल की पहली लाइन खाली नहीं है, तो यह अगली चार लाइनें पढ़ता है। गणना उन रेखाओं पर की जाती है और फिर अगली पंक्ति पढ़ी जाती है। यदि वह रेखा खाली नहीं है तो यह जारी रहती है। हालाँकि, मुझे यह त्रुटि मिल रही है:
ValueError: invalid literal for int() with base 10: ''.
यह पहली पंक्ति पढ़ रहा है, लेकिन इसे पूर्णांक में परिवर्तित नहीं कर सकता।
इस समस्या को सुलझाने में मैं क्या कर सकता हूं?
कोड:
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:वहां उपयोग करने पर विचार करना चाहिए ।