[portland] Script to Change UPPER CASE to Mixed Case

Rami Kassab rami at typethink.com
Tue Sep 22 02:35:07 CEST 2009

Rich, I believe what you're referring to is Title Case. Python has a built
in method for strings called title(), which you could use but it doesn't
take into account small words. I found this method,
that follows some rules from the New York Times for title casing.
As for a way to automate this for your CSV, it might be difficult to find a
pre-written script that does that and title cases for you but it's very
trivial to use the Python CSV reader library and just loop through each
line, run a title case method on the fields you want, and save the output.

Hope this helps. Good luck!

*Rami Kassab* - Chief Executive Officer
M 503.888.8605
rami at typethink.com
LinkedIn Profile <http://www.linkedin.com/in/RamiKassab>

*Typethink* - Creative Web Firm
P 503.626.6231
F 503.626.6233
111 SW 5th Ave., Suite 1000
Portland, OR 97204

On Mon, Sep 21, 2009 at 5:10 PM, Rich Shepard <rshepard at appl-ecosys.com>wrote:

>  Before I re-invent the wheel I'm looking for a script that will read a
> text file and convert all uppercase strings to proper case (i.e., first
> letter capitalized, all others lowercase). I don't find one in the Python
> Cookbook.
>  I've downloaded -- as .csv files -- a bunch of databases from an Oregon
> state agency. It's obvious from the different formats used for the same
> fields that their SQL Server application does no checking to ensure that
> all
> data are entered in a uniform way. Because I don't like to have database
> records like this, and I don't want to manually correct several thousand
> records, I'd like a script to do the work for me.
>  Each row has 25 columns; 22 are TEXT, one is INTEGER, and two are REAL.
> The text fields are almost all in uppercase; but not all are.
>  I'd appreciate pointers to where I might find such a script through which
> I can pass the text file.
> TIA,
> Rich
> _______________________________________________
> Portland mailing list
> Portland at python.org
> http://mail.python.org/mailman/listinfo/portland
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/portland/attachments/20090921/56332038/attachment.htm>

More information about the Portland mailing list