Strict Standards: Declaration of Doku_Renderer_metadata::table_open() should be compatible with Doku_Renderer::table_open($maxcols = NULL, $numrows = NULL, $pos = NULL) in /home2/cp-wiki/htdocs/inc/parser/metadata.php on line 480

Strict Standards: Declaration of Doku_Renderer_metadata::table_close() should be compatible with Doku_Renderer::table_close($pos = NULL) in /home2/cp-wiki/htdocs/inc/parser/metadata.php on line 480

A slight variation of what was given in class…

import string

def main(search):
    total = 0
    c = 0
    
    infile = open("birdlist48.csv")
    infile.readline()
    infile.readline()

    for line in infile:
        # print line
        fields = string.split(line, ",")
        if fields[0]:
            order = string.capwords(fields[0])
        name = fields[6]
        if name:
            total = total + 1
        if name and string.find(string.lower(name), search) >= 0:
            c = c + 1
            genus = fields[4]
            species = fields[5]
            print "%-30s (%s %s, order %s)" % (name, genus, species, order)
    print "%d birds, of which %d match %s" % (total, c, search)
    
main("hawk")

The version developed in class…

import string

def main(search):
    total = 0
    c = 0
    
    infile = open("birdlist48.csv")
    infile.readline()
    infile.readline()

    for line in infile:
        # print line
        fields = string.split(line, ",")
        if fields[0]:
            order = string.capwords(fields[0])
        name = fields[6]
        if name:
            total = total + 1
        if name and string.find(string.lower(name), search) >= 0:
            c = c + 1
            genus = fields[4]
            species = fields[5]
            print "%-30s (%s %s, order %s)" % (name, genus, species, order)
    print "%d birds, of which %d match %s" % (total, c, search)
    
main("hawk")

 
bird.txt · Last modified: 2008/01/17 08:57 by jtk
 
Recent changes RSS feed Creative Commons License Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki