Software Development
Member Avatar

hi I want to know the easyest way to readline() or readlines() or read()
a file so far I have this

>>> file = open( 'write_total.txt', 'r' )
>>> file.readlines() …
Topic by trade19

I don't know how but it finnaly got to the point where it all works perfect.
Thanks for all your help

num=1
number_lst=[]
with open("C:\\write_it.txt", "r") as totals:
    for line …
Software Development
Member Avatar

hi I want to know the easyest way to readline() or readlines() or read()
a file so far I have this

>>> file = open( 'write_total.txt', 'r' )
>>> file.readlines() …
Topic by trade19

Iam getting the output totals of 76.0 and I think that is the 009 item counted. I can't seem to get out of the Index Error.

So it wont jump …

Software Development
Member Avatar

hi I want to know the easyest way to readline() or readlines() or read()
a file so far I have this

>>> file = open( 'write_total.txt', 'r' )
>>> file.readlines() …
Topic by trade19

I still can't get rid of this error
is it due to eof ? or end of line?

Traceback (most recent call last):
  File "C:\Python33\testkill.py", line 22, in <module>
    number_lst.append(float(line[1])) …
Software Development
Member Avatar

hi I want to know the easyest way to readline() or readlines() or read()
a file so far I have this

>>> file = open( 'write_total.txt', 'r' )
>>> file.readlines() …
Topic by trade19

ok I will check it

Software Development
Member Avatar

hi I want to know the easyest way to readline() or readlines() or read()
a file so far I have this

>>> file = open( 'write_total.txt', 'r' )
>>> file.readlines() …
Topic by trade19

The only issue I have is to change the list.
The result equals say: 54.0 but I can't seem to find what represents the amount of 54.0 I tried type …

Software Development
Member Avatar

hi I want to know the easyest way to readline() or readlines() or read()
a file so far I have this

>>> file = open( 'write_total.txt', 'r' )
>>> file.readlines() …
Topic by trade19

Ok I put all you gave me toghether like this and it all works fine.
Thanks snipsat

num=1
number_lst=[]

with open("C:\\write_it.txt", "r") as totals:
    for line in totals:

        print('% 04d …
Software Development
Member Avatar

hi I want to know the easyest way to readline() or readlines() or read()
a file so far I have this

>>> file = open( 'write_total.txt', 'r' )
>>> file.readlines() …
Topic by trade19

What am I missing?

Software Development
Member Avatar

hi I want to know the easyest way to readline() or readlines() or read()
a file so far I have this

>>> file = open( 'write_total.txt', 'r' )
>>> file.readlines() …
Topic by trade19

This is the part that writes to the fileor appends rather:

totals = open("C:\\write_it.txt", "a")
        totals.write('$%.2f \n'  % totalc)
        totals.close()

I can try removing the

\n

This is what is …

Software Development
Member Avatar

hi I want to know the easyest way to readline() or readlines() or read()
a file so far I have this

>>> file = open( 'write_total.txt', 'r' )
>>> file.readlines() …
Topic by trade19

Iam also using notepad
how does it work without "C:\number.txt"mine won't work without the C:\ part
I also needed to change

number_lst = []

I needed to change to

number_lst=[] …
Software Development
Member Avatar

hi I want to know the easyest way to readline() or readlines() or read()
a file so far I have this

>>> file = open( 'write_total.txt', 'r' )
>>> file.readlines() …
Topic by trade19

Not sure if this will help me but....This is the file: This how the program writes the $10.00 too the file.
Iam also using notepad
how does it work without …

Software Development
Member Avatar

hi I want to know the easyest way to readline() or readlines() or read()
a file so far I have this

>>> file = open( 'write_total.txt', 'r' )
>>> file.readlines() …
Topic by trade19

and this is the file:
$10.00
$8.00
$10.00
$6.00
$10.00
$10.00

Software Development
Member Avatar

hi I want to know the easyest way to readline() or readlines() or read()
a file so far I have this

>>> file = open( 'write_total.txt', 'r' )
>>> file.readlines() …
Topic by trade19

this is the code I used:

totals = open('write_it.txt')
total_lst = totals.readlines()
number_lst = []
for line in total_lst:

    line=line.strip().split('$')
    number_lst.append(float(line[1]))
    print(number_lst) #[10.0, 10.0, 10.0, 10.0, 10.0, 10.0]
    print(sum(number_lst)) #60.0 …
Software Development
Member Avatar

hi I want to know the easyest way to readline() or readlines() or read()
a file so far I have this

>>> file = open( 'write_total.txt', 'r' )
>>> file.readlines() …
Topic by trade19

I got this error:

Traceback (most recent call last):
  File "C:\Python33\keep2.py", line 34, in <module>
    number_lst.append(float(line[1]))
IndexError: list index out of range
Software Development
Member Avatar

hi I want to know the easyest way to readline() or readlines() or read()
a file so far I have this

>>> file = open( 'write_total.txt', 'r' )
>>> file.readlines() …
Topic by trade19

also i forgot to mention each time I run the program a new amount is added to the file like this:

$10.00 
$8.00 
$10.00 
$6.00
$10.00 
$10.00 
$8.00 
$10.00 
$6.00 …
Software Development
Member Avatar

hi I want to know the easyest way to readline() or readlines() or read()
a file so far I have this

>>> file = open( 'write_total.txt', 'r' )
>>> file.readlines() …
Topic by trade19

can you help me doing the same thing using the code below?
also in my version
As it is the code below wont work

print ('won't work unless I use') …
Software Development
Member Avatar

hi I want to know the easyest way to readline() or readlines() or read()
a file so far I have this

>>> file = open( 'write_total.txt', 'r' )
>>> file.readlines() …
Topic by trade19

ok thanks so much I will try this and get back to you.
print [float(i.split('$')[1])#########for i in lst]
I got a syntax error where I put the #######
I am …

Software Development
Member Avatar

hi I want to know the easyest way to readline() or readlines() or read()
a file so far I have this

>>> file = open( 'write_total.txt', 'r' )
>>> file.readlines() …
Software Development
Member Avatar

hi I want to know the easyest way to readline() or readlines() or read()
a file so far I have this

>>> file = open( 'write_total.txt', 'r' )
>>> file.readlines() …
Software Development
Member Avatar

python3
Hi I am trying to compare these two (strings) of numbers.

There may not be a space inbetween the numbers in the file, but here its just for clearity. …

Topic by trade19

Hi i have been using this site for info I dont think it is python 3 but it is helpful to me because its layout.

http://www.java2s.com/Code/Python/2D1.htm

So far this all …

Software Development
Member Avatar

python3
Hi I am trying to compare these two (strings) of numbers.

There may not be a space inbetween the numbers in the file, but here its just for clearity. …

Topic by trade19

Win Number is ['12', '25', '34', '42', '59', '-', '19']
['12', '25', '34', '42', '59', '-', '19'] (5, 1)
['02', '06', '14', '17', '39', '-', '33'] (0, 0)
This would …

Software Development
Member Avatar

python3
Hi I am trying to compare these two (strings) of numbers.

There may not be a space inbetween the numbers in the file, but here its just for clearity. …

Topic by trade19

ok This did not work or I did it wrong
if I have results like this (3,1) I am looking for a comparision
variable like (a,b)like if a=>3 and b>0 …

Software Development
Member Avatar

python3
Hi I am trying to compare these two (strings) of numbers.

There may not be a space inbetween the numbers in the file, but here its just for clearity. …

Topic by trade19

Ok I have tried to fix some of the indents
So far this code should work minus the errors with tk frame stuff
it should work as far as the …

Software Development
Member Avatar

python3
Hi I am trying to compare these two (strings) of numbers.

There may not be a space inbetween the numbers in the file, but here its just for clearity. …

Topic by trade19

I did this and got some data but not the comparision.
Iam still not able to read the target variable from the file and had to put it in as …

Software Development
Member Avatar

python3
Hi I am trying to compare these two (strings) of numbers.

There may not be a space inbetween the numbers in the file, but here its just for clearity. …

Topic by trade19

ok I understand this code I can just adapt it to read from a file.

I don't know how to adapt from the File output.txt

data = open("C:\output.txt","r")
    data= [line.split() …
Software Development
Member Avatar

python3
Hi I am trying to compare these two (strings) of numbers.

There may not be a space inbetween the numbers in the file, but here its just for clearity. …

Topic by trade19

This is the program so far.
I know it has MANY flaws though as it is it works up to the COMPARE button.

from tkinter import*
import sys, random, tkinter …
Software Development
Member Avatar

python3
Hi I am trying to compare these two (strings) of numbers.

There may not be a space inbetween the numbers in the file, but here its just for clearity. …

Topic by trade19

What I want is to compare each record at a time starting with
13 27 34 41 47 - 49 compared with 07 13 14 23 45 - 07
This …

Software Development
Member Avatar

python3
Hi I am trying to compare these two (strings) of numbers.

There may not be a space inbetween the numbers in the file, but here its just for clearity. …

Topic by trade19

Wow! you guys realy lost me, I have'nt realy got to this level.
So I don't understand what you did.
From what I try to understand, is that you separated …

Software Development
Member Avatar

python3
Hi I am trying to compare these two (strings) of numbers.

There may not be a space inbetween the numbers in the file, but here its just for clearity. …

Topic by trade19

I did this and tested it for the six number to flaw and it never did after 100's of tries. So I think this works for one set of numbers …

Software Development
Member Avatar

python3
Hi I am trying to compare these two (strings) of numbers.

There may not be a space inbetween the numbers in the file, but here its just for clearity. …

Topic by trade19

ok I read the link you gave me.
It is very informative though I don't understand it all.
Example: This file
06 15 26 34 36 - 16
16 24 …

Software Development
Member Avatar

python3
Hi I am trying to compare these two (strings) of numbers.

There may not be a space inbetween the numbers in the file, but here its just for clearity. …

Topic by trade19

s[2:4]equaled the first one 09
and s[4:8] equaled the second one 12
next one did'nt work, So I have no idea how to pick out the specific number. oh i …