Fixed-length text file to database script

Michael Ströder michael at stroeder.com
Thu Aug 14 02:01:31 CEST 2008


Larry Bates wrote:
> ssharpjr at gmail.com wrote:
>> 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 need to know how to write a script that will DAILY pull this text
>> file into a MySQL database.
> 
> 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.).

If the input data has to be pre-processed before storing it into the 
database a Python script would be needed.

Just in case somebody needs a module for reading fixed-length files in 
the spirit of module csv:

   http://www.stroeder.com/pylib/fixedlenfields.py

For the MySQL part:
http://mysql-python.sourceforge.net/

Ciao, Michael.



More information about the Python-list mailing list