2011/5/10 Jean-Baptiste Marquette <marquett@iap.fr>
Hi all,

This is my first attempt to use Jython, I wrote the following code :

#!/usr/bin/env jython

# Construit les catalogues par champ

import sys
import glob
import stilts

for ChampList in glob.glob('*.chplst'):
   Obj = ChampList[0:2]
   Cat = Obj + '_all.dat'
   OpenCat = stilts.tread(Cat, fmt='ascii')
   OpenList = stilts.tread(ChampList, fmt='ascii')
   for Champ in OpenList.coldata(0):
       CatChamp = Champ + '.dat'
       print Champ, 'processing'
       OpenCat.cmd_select('startsWith(StarId, "Champ")').write(CatChamp, fmt='ascii')

The module stilts contains cmd_select and startsWith. This function searches for the string contained in Champ (for example 'bs300') at the beginning of the string in StarId (for example 'bs3000k7012'). But "Champ" is interpreted as a string itself, so I got empty files CatChamp but the header, because there is no StarId starting with the string 'Champ'.

Thus, what could be the correct syntax to use for the variable Champ ?

Write Champ instead of "Champ" in quote. Or an expression of type String. Or I don't understand....

Thanks for your help,

JB Marquette

Achieve unprecedented app performance and reliability
What every C/C++ and Fortran developer should know.
Learn how Intel has extended the reach of its next-generation tools
to help boost performance applications - inlcuding clusters.
Jython-users mailing list



My blog and profile (http://pierrethibault.posterous.com)
YouTube page (http://www.youtube.com/user/tubetib)
Twitter (http://twitter.com/pierreth2)