[Tutor] unicode to plain text conversion
MPirritano at ochca.com
Tue Apr 7 00:48:05 CEST 2009
Hello python people,
I am a total newbie. I have a very large file > 4GB that I need to
convert from Unicode to plain text. I used to just use dos when the file
was < 4GB but it no longer seems to work. Can anyone point me to some
python code that might perform this function?
Matthew Pirritano, Ph.D.
Research Analyst IV
Medical Services Initiative (MSI)
Orange County Health Care Agency
From: tutor-bounces+mpirritano=ochca.com at python.org
[mailto:tutor-bounces+mpirritano=ochca.com at python.org] On Behalf Of
Sent: Monday, April 06, 2009 12:31 AM
To: Python Tutor
Subject: [Tutor] Checking for string in a list strangeness
I'm writing a small cgi application for children to use and I want to
check that the name they enter isn't a swear word.
I've populated a database with a swear word list and then check this
list against the input, but it always shows up as not being a swear
Can anyone see why this would always throw up FALSE, even if I supply
a word which is in the list?
Code (with some of my debugging - so this is not the finished article).
from random import *
from cgi import *
import cgitb; cgitb.enable()
print "Content-type: text/html\n\n"
except MySQLdb.Error, e:
print "Error %d %s" %(e.args, e.args)
mycursor = connection.cursor()
print """<h1>Join the game</h1>"""
print """<form action = "join.py" method=get>
<input type = text name = "team" />
<input type = "Submit" value="Join" />
#Popluate my swear word list from the db.
mycursor.execute("select badword from badwords")
myrowcount = int(mycursor.rowcount)
swearlist = 
for i in range (0, myrowcount):
myrow = mycursor.fetchone()
team = FieldStorage()
#Need some kind of swear checker here.
#for i in swearlist: # shows swear list OK
# print i;
checkteam = team.getvalue('team')
#print """<p>"""+str (checkteam) + """</p>"""; # this works OK
# As does this
print "name = " + str(team.getvalue('team'))
if str(team.getvalue('team')) in swearlist: # This is
print "not swearing"
if team.getvalue('team') in swearlist: #This
also is fail.
print "no swear"
team = team.getvalue('team')
statement = """insert into pupil (nickname, points, played,
morepoints, moreplayed, footballteam) values ('""" + team + """',
print """<br />You have now joined.<br /><a
href="/times/football/football.py">You should now support a
# disconnect the database
You back your data up on the same planet?
PGP key: 0x7111B833
Tutor maillist - Tutor at python.org
More information about the Tutor