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, http://muffinresearch.co.uk/archives/2008/05/27/titlecasepy-titlecase-in-python/, 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 [email protected] 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 www.typethink.com On Mon, Sep 21, 2009 at 5:10 PM, Rich Shepard <[email protected]>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 > [email protected] > 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> _______________________________________________ Portland mailing list [email protected] http://mail.python.org/mailman/listinfo/portland
