Fixed-length text file to database script

Larry Bates larry.bates at websafe.com`
Thu Aug 14 12:52:39 EDT 2008


Michael Ströder wrote:
> 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.

While you are correct, that is not what the OP asked.  There is no reference to 
processing data prior to insertion into MySQL database.  Also the OP said they 
had a 1 day deadline.

-Larry



More information about the Python-list mailing list