invalid literal for int with base 10

0 votes

In order to create a program which can read the file and the starting line on the file is not empty or blank, which further enables the next four lines to be deciphered, what must one do? The calculations are performed on the lines and then the next line is readable. However, if that line isn’t empty, it still continues. However, this error persists:


ValueError: invalid literal for int() with base 10
 

Despite being able to understand and read the line at the start, the process of converting it to an integer is not working for me. What can I do to fix this problem?

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())
Feb 8 in Python by Rahul
• 8,980 points
23 views

1 answer to this question.

0 votes

In order to solve this problem, one must use the following lines of code:-
 

>>> int('55063.000000') 
Traceback (most recent call last): 
File "<stdin>", line 1, in <module> 
ValueError: invalid literal for int() with base 10: '55063.000000'


Which brings the user to this and must be used to avoid the problem of non conversion to the integer:-
 

>>> int(float('55063.000000')) 55063
answered Feb 8 by Soham
• 8,730 points

Related Questions In Python

+1 vote
10 answers

How to fix this? ValueError: invalid literal for int() with base 10 error in Python

Just for the record: >>> int('55063.000000') Traceback (most recent ...READ MORE

answered Aug 17, 2020 in Python by pakainfo
• 200 points
354,812 views
0 votes
1 answer

Error is "invalid literal for int() with base 10: ' ' "

This error is caused because we try ...READ MORE

answered Oct 15, 2020 in Python by Gitika
• 65,850 points
1,663 views
0 votes
1 answer

invalid literal for int() with base 10 in python

Hello, You can try this simple code: def getSum(n): ...READ MORE

answered Nov 23, 2020 in Python by Niroj
• 82,680 points
796 views
0 votes
1 answer

OSX 10.11 with py2app?

I'm not sure if this is your ...READ MORE

answered May 9, 2018 in Python by charlie_brown
• 7,710 points
732 views
0 votes
1 answer

'Syntax Error: invalid syntax' for no apparent reason

You're missing a close paren in this ...READ MORE

answered Aug 13, 2018 in Python by Priyaj
• 58,060 points
1,633 views
0 votes
2 answers
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 7, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 2,745 views
0 votes
1 answer
0 votes
2 answers

Replacements for switch statement in Python?

The recommended path for Python 3.10 which ...READ MORE

answered Feb 9 in Python by Soham
• 8,730 points
152 views
webinar REGISTER FOR FREE WEBINAR X
Send OTP
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP