Re: Fixed-length text file to database script

2008-08-15 Thread Lie
On Aug 15, 7:12 am, John Machin <[EMAIL PROTECTED]> wrote: > On Aug 15, 4:55 am, [EMAIL PROTECTED] wrote: > > > #your thought is right. > > === > > def sizes2fields(sizes): > >    d = [] > >    begin = 0 > >    for i in sizes: > >       if begin:

Re: Fixed-length text file to database script

2008-08-14 Thread John Machin
On Aug 15, 4:55 am, [EMAIL PROTECTED] wrote: > #your thought is right. > === > def sizes2fields(sizes): >d = [] >begin = 0 >for i in sizes: > if begin: > end = begin + i > else: end = i > d.append((begin, end

RE: Fixed-length text file to database script

2008-08-14 Thread Edwin . Madari
prints out: ('1234567890123456', '7890', '12345678', '90123456', '78901234') hope it helps. thanks Edwin -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Eric Wertman Sent: Thursday, August 14, 2008 1:59 PM To: python-lis

Re: Fixed-length text file to database script

2008-08-14 Thread Michael Ströder
Larry Bates wrote: 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, having a bad day? I'm confident that the OP is able to sort out *himself* what he need

Re: Fixed-length text file to database script

2008-08-14 Thread Eric Wertman
Sorry, didn't get to finish my script. Have to figure out the deal with gmail and the tab key someday. myfile = '/somewhere/somefile.txt' sizes = [16,4,8,8,8] fd = open(myfile,r) data = [] for line in fd.readlines() : a = [] idx1 = 0 for l in sizes : idx2 = idx1 + l

Re: Fixed-length text file to database script

2008-08-14 Thread Eric Wertman
I have a machine (PLC) that is dumping its test results into a fixed- length text file. While it has nothing to do with python, I found that creating a MySQL table with the proper fixed length char() fields and using 'load data infile' was the easiest way to deal with that sort of scenario. T

Re: Fixed-length text file to database script

2008-08-14 Thread Larry Bates
Michael Ströder wrote: Larry Bates wrote: [EMAIL PROTECTED] 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 en

RE: Fixed-length text file to database script

2008-08-14 Thread Edwin . Madari
ECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Diez B. Roggisch Sent: Thursday, August 14, 2008 7:11 AM To: python-list@python.org Subject: Re: Fixed-length text file to database script Stacey wrote: > Hi Guys, > > I'm new to Python (mostly) and I'm wanting to use it for a new

Re: Fixed-length text file to database script

2008-08-14 Thread Diez B. Roggisch
Stacey 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

Re: Fixed-length text file to database script

2008-08-13 Thread Michael Ströder
Larry Bates wrote: [EMAIL PROTECTED] 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

Re: Fixed-length text file to database script

2008-08-13 Thread Larry Bates
[EMAIL PROTECTED] 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

Fixed-length text file to database script

2008-08-13 Thread Stacey
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 crea

Fixed-length text file to database script

2008-08-13 Thread ssharpjr
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 cre