jump to navigation

Solving data entry with Python… July 8, 2007

Posted by Phill in Scripting.
trackback

Do you ever have the scenario where you get some data you need to input into a database, except that it’s in a format not really conducive to data entry… HTML, for example. The other day I got sent a bunch of credit card information (test data, I might add) which needed to be input into a table. The only problem was, it was in an email (HTML).

The problem was, it wasn’t a huge amount of data (40 or 50 records) — long enough to not want to enter in each one by hand, but not long enough to spend too much time on.

What I did in the end was copy and paste the data into Excel, export it as a CSV file, and then use Python‘s built-in CSV-parsing features to create a bunch of SQL statements to insert the data (unfortunately I couldn’t just load it up using the raw CSV data as it needed a bit of pre-processing).

It did get me thinking… what would have been the best way from getting that data across from the email to the database? That’s not a rhetorical question, by the way — answers on a postcard! (or, you could just leave a comment). What is the best way of dealing with data in unusual formats?

Advertisements
%d bloggers like this: