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 24

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 24

Warning: Cannot modify header information - headers already sent by (output started at /home2/cp-wiki/htdocs/inc/parser/metadata.php:24) in /home2/cp-wiki/htdocs/inc/actions.php on line 581

Warning: Cannot modify header information - headers already sent by (output started at /home2/cp-wiki/htdocs/inc/parser/metadata.php:24) in /home2/cp-wiki/htdocs/inc/actions.php on line 581
bird

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")