Re: read numbers from file and covert to integer

2005-01-09 Thread beliavsky
If you have a file "ints.txt" with contents 10 20 30 40 50 60 You could read integers into a list with ivec = [] for text in open("ints.txt","r"): words = text.split() for x in words: ivec.append(int(x)) print ivec If you know you want to read two integers into variables a,b from a line you cou

Re: read numbers from file and covert to integer

2005-01-09 Thread Peter Hansen
Øystein Western wrote: I got a file with a lot blocks of numbers that are strings. I'd like to read all this numbers and convert them to numbers for futher compareation. How can I convert all this numbers to integer? Do I have to put all numbers into a list? It would help immensely if you could p