Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

python reading into a text file and diplaying items in a user friendly manner

def extract_data(filename):
    infile = open(filename, 'r')
    infile.readline()  # skip the first line
    data = [line.split() for line in infile]
    annual_avg = data[-1][1]
    data = [(m, float(r)) for m, r in data[:-1]]
    infile.close()
    return data, annual_avg
Source by hplgit.github.io #
 
PREVIOUS NEXT
Tagged: #python #reading #text #file #diplaying #items #user #friendly #manner
ADD COMMENT
Topic
Name
3+6 =