[Tutor] Reading binary files #2

2009-02-09 Thread etrade . griffiths
Hi following last week's discussion with Bob Gailer about reading unformatted FORTRAN files, I have attached an example of the file in ASCII format and the equivalent unformatted version. Below is some code that works OK until it gets to a data item that has no additional associated data, the

Re: [Tutor] reading binary files

2009-02-03 Thread etrade . griffiths
Sorry, still having problems > > I am trying to read data from a file that has format > > item_name num_items item_type items > > > > eg > > > > TIME 1 0.0 > > DISTANCE 10 0.0 1.0 2.0 3.0 4.0 5.0 6.0 7.0 8.0 9.0 > > Where is the item_type? Ooops, the data format should loo

[Tutor] reading binary files

2009-02-02 Thread etrade . griffiths
Hi I am trying to read data from a file that has format item_name num_items item_type items eg TIME 1 0.0 DISTANCE 10 0.0 1.0 2.0 3.0 4.0 5.0 6.0 7.0 8.0 9.0 TIME 1 1.0 DISTANCE 10 1.0 2.0 3.0 4.0 5.0 6.0 7.0 8.0 9.0 10.0 I can read this if the data are in ASCII format us

[Tutor] How many loops does "break" jump out of?

2007-02-22 Thread etrade . griffiths
Am trying to convert a C program with a GOTO in it to Python and was wondering how many loops a Python "break" jumps out of. Here is the C pseudo code if (test_1) { for (;;) { if (test_2) { do_stuff(); } else if (test_2) { for (ip=m1+m2+1;ip<=m;ip++) {

Re: [Tutor] Alternatives to PY2EXE

2006-11-16 Thread etrade . griffiths
Thanks for the various advice(s) re PY2EXE alternatives. I considered installing Python on the target machines but though it would be simpler to install the EXE as I has done with C++ apps. Boy, how naive was that? Using PY2EXE is not straightforward and the documentation is fairly poor IMHO.

Re: [Tutor] Use of dateutil.relativedata

2006-11-15 Thread Etrade Griffiths
Sorry, problem solved import datetime import dateutil.relativedelta x=datetime.date.today() y=x+datetime.timedelta(days=366) z=y-x print x,y,z a=dateutil.relativedelta.relativedelta(x,y) print a seems to do the trick ___ Tutor maillist - Tutor@py

[Tutor] Use of dateutil.relativedata

2006-11-15 Thread Etrade Griffiths
Hi trying to use dateutil to calculate the number of months between two dates. here is the script import datetime import dateutil x=datetime.date.today() y=x+datetime.timedelta(days=366) z=y-x print x,y,z a=dateutil.relativedelta(x,y) print a and here is the output >>> 2006-11-15 2007-11

[Tutor] Alternatives to PY2EXE

2006-11-14 Thread Etrade Griffiths
Hi just finished developing my first app with wxPython and matplotlib and now trying to create an EXE file using PY2EXE for distribution. However, this is proving to be an extremely frustrating experience and I am making very little progress. Are there any "simple" alternatives to PY2EXE for

Re: [Tutor] Getting the type of a variable

2006-10-27 Thread Etrade Griffiths
Thanks, guys - like so many things, easy when you know how! Alun Griffiths At 14:27 27/10/2006, you wrote: Use this:   if type(a) == type(1):     print "a is int %d" elif type(a) == type(1.1):   ...   HTH.. Regards, Asrarahmed Kadri   On 10/27/06, Etrade Griffiths <[EMAIL PROT

[Tutor] Getting the type of a variable

2006-10-27 Thread Etrade Griffiths
Hi I want to check the type of a variable so that I know which format to use for printing eg def print_correct_format(a): if type(a) == 'int': print "a is an integer, value %i" % (a) elif type(a) == 'float': print "a is a float, value %f" % (a)

[Tutor] Sharing data between modules

2006-10-19 Thread etrade . griffiths
Hi just starting to get to grips with writing GUIs in Python using wxPython and not being a computer scientist, have a philosophical question about the "best" way to pass data between various modules. For example, I anticipate having one module to look after the GUI stuff where users can input

Re: [Tutor] Traversing Excel Columns

2006-09-12 Thread Etrade Griffiths
Chris are you looking for something like this? xlSht=xlApp.Worksheets("Sheet1") irow=1 XL_row_has_data=1 while XL_row_has_data: xlRng=xlSht.Range(xlSht.Cells(irow,1),xlSht.Cells(irow,256)) ncell=xlApp.WorksheetFunction.CountA(xlRng) if ncell ==0: # Cells in current row

Re: [Tutor] Running DOS jobs in batch

2006-09-07 Thread Etrade Griffiths
Thanks for that Kent.  I did imex_exe=r'C:\Program Files\CMG\IMEX\2005.10\EXE\mx200510.exe' imex_args=('mx200510.exe','-f',imex_fil,'-wd','"'+work_dir+'"') for n in range(1,nscen): os.spawnv(os.P_WAIT, imex_exe, imex_args) and it seems to work.  Not sure why I need to provide the name of

[Tutor] Running DOS jobs in batch

2006-09-07 Thread Etrade Griffiths
Hi I am trying to write a PYTHON script that automates the running of an application program MX200510.EXE under XP Pro via a DOS window. This file is in directory C:\Program Files\CMG\IMEX\2005.10\EXE The command line arguments are MX200510.EXE -f "temp.dat" -wd "C:\Projects\Vitol\New busin

[Tutor] Confused about globals

2006-06-09 Thread Etrade Griffiths
Hi I have a series of python programs that plot stuff using PYX. Common to these is the need to read in a list of (well) locations in (X,Y) coords so I put that code in a separate module called shared_funcs.py. The coords are stored in dictionaries which I want to use later in the "main" prog

Re: [Tutor] unpacking PyTime

2006-05-17 Thread Etrade Griffiths
/2006, Bob Gailer wrote: >Etrade Griffiths wrote: >>Hi >> >>I am using the Win32com library to pick up data from an EXCEL spreadsheet >>but am having trouble with dates. I want to convert a date read from the >>XL sheet into a float using this snippet >>

[Tutor] unpacking PyTime

2006-05-17 Thread Etrade Griffiths
Hi I am using the Win32com library to pick up data from an EXCEL spreadsheet but am having trouble with dates. I want to convert a date read from the XL sheet into a float using this snippet from win32com.client import dispatch import time xlFile="test.xls" xlApp=Dispatch("Excel.Application")

Re: [Tutor] Looping over lists of objects

2006-04-24 Thread Etrade Griffiths
24/04/06, Etrade Griffiths <[EMAIL PROTECTED]> wrote: > > Hi > > > > just feeling my way into Python with a small app that reads data from > > file, creates objects using that data, stores the objects in a list, loops > > over the list doing comparison tests to f

[Tutor] Looping over lists of objects

2006-04-24 Thread Etrade Griffiths
Hi just feeling my way into Python with a  small app that reads data from file, creates objects using that data, stores the objects in a list, loops over the list doing comparison tests to filter out various objects.  Here is a code snippet: class myObj:     def __init__(self,a,b):     self.a

Re: [Tutor] First steps with Tkinter

2006-01-27 Thread Etrade Griffiths
Catherine I'm a Python newbie too but have done some programming with C++ Builder so have a little knowledge of GUIs etc Best regards Alun At 22:41 26/01/2006, catherine curley wrote: Alan   As a matter of interest, did you have much knowledge of Python before you tried TKinter?  I'm only a pyth

[Tutor] First steps with Tkinter

2006-01-26 Thread etrade . griffiths
Hi! Just started trying to get to grips with Python and Tkinter. Have Frederick Lundh's tutorial and am on program hello2.py which looks like this # File: hello2.py from Tkinter import * class App: def __init__(self, master): frame = Frame(master) frame.pack() s