Fixed-length text file to database script

Larry Bates larry.bates at websafe.com`
Wed Aug 13 18:47:28 EDT 2008


ssharpjr at gmail.com wrote:
> Hi Guys,
> 
> I'm new to Python (mostly) and I'm wanting to use it for a new project
> I'm faced with.
> 
> I have a machine (PLC) that is dumping its test results into a fixed-
> length text file.  I need to pull this data into a database (MySQL
> most likely) so that I can access it with Crystal Reports to create
> daily reports for my engineers.
> 
> I've been reading the Python manual for about a week now and I'm
> learning a lot.  Unfortunately, I was given a deadline today that I
> cannot meet without a little help.
> 
> I need to know how to write a script that will DAILY pull this text
> file into a MySQL database.
> 
> Can anyone show me how to do this?
> 
> Thanks
> 
> Stacey

Just use the built in import SQL statement to import the information.  You don't 
really need a Python script.  import can handle fixed field records (as well as 
CSV, etc.).

-Larry



More information about the Python-list mailing list