All pastes #759466 Raw Edit

Anonymous

public text v1 · immutable
·published 2007-11-03 04:07 UTC
rendered paste body
#######################################################
comment: NOTE THIS SECTION IS THE FILE: sample_file.txt


Burger Hut:36.32:8.27:9.36
Shultzey's:54.08:9.95:3.57
Thai Tom:89.37:6.75:4.42
Thai-ger Room:92.1:3.66:8.17
Fresh Flowers:44.38:11.05:9.11


comment: file ends here
#######################################################

def file_to_dictionary(file):
    lines = {}
    i = 0
    def read_file (f):   
        for line in f:
            yield line.split(":")
           
    for x in read_file(open('sample_file.txt')):
        temp = '' 
        for y in x:         
            if y.isalpha():
                temp = y.strip("\n")
            else:
                lines [temp] = float(y.strip())
    return lines


print file_to_dictionary (open('sample_file.txt'))