Thank you Jay. It worked, I am V.V.happy. I tried
Liam's suggestion also, but some weird things are
going and I am not only getting results but also any
error. I am working on that.
Other thing.
I a feeding my parser some coordinates specified by
me, where I am asking the parser to extract the
intensity values only for those coordinates.
For exmple:
Coordinates_file = open('xxx','r')
def coOrs(coordinates_file):
...................
..................
## this parse extracts the my specified coordinates#
## and saves as a list for lookup in Intensity
File##
return my_coordinates_list
def intPars
er(Intensity File, my_coordinates_list):
................................
...............................
return intensities
This above f(x) returns intensities and my
coordinates.
Now that I am reading many files at once, I wanted, to
have a tab delim file op that looks like this:
My_coors Int_file 1 Int_file2
IntFile3
01:26 34 235
245.45
04:42 342.4 452.4 45.5
02:56 45.4 34.5 557.8
code:
files = glob.glob("My_dir\*.ext")
def parSer(file):
f1 = open(file,'r')
seelf = f1.read().split('\n')
seelfile = seelf[24:506969]
my_vals = intParser(seelfile,pbs)
f2 = open(file+'.txt','w')
for line in my_vals:
f2.write(line+'\t') => asking for tab delim..
f2.write('\n')
f2.close()
def main():
for each in files:
parSer(each)
main()
=> putting here a '\t' did not work.. .
Am i wrong here. Any suggestions, please.
Thank you in advance.
--- Jay Loden <[EMAIL PROTECTED]> wrote:
> There's a few ways to accomplish this...the way that
> comes to mind is:
>
>
##########################################################
> import glob
>
> files = glob.glob("/path/to/director/*.dml") #
> assuming you want only .dml
>
> def spot(file):
> '''search for intensity spots and report them to
> an output file'''
> f1 = open('my_intensity_file.dml','r')
> int = f1.read().split('\n')
>
> my_vals = intParser(int)
>
> intParser return a list
> f2 = open('myvalues.txt','w') # you will want to
> change this to output mult
> for line in my_vals: # files, or to at least
> append instead of overwriting
> f2.write(line)
> f2.write('\n')
> f2.close()
>
> def main():
> for each in files:
> spot(each)
>
> main()
>
>
##########################################################
>
> Basically, turn the parsing into a function, then
> create a list of files, and
> perform the parsing on each file. glob() lets you
> grab a whole list of files
> matching the wildcard just like if you typed "ls
> *.dml" or whatever into a
> command prompt. There wasn't too much info about
> specifically how you needed
> this to work, so this is a rough sketch of what you
> want. Hopefully it helps.
>
> -Jay
>
> On Sunday 30 January 2005 03:03 am, kumar s wrote:
> > Hello.
> >
> > I wrote a parser to parse spot intensities. The
> input
> > to this parser i am giving one single file
> >
> > f1 = open('my_intensity_file.dml','r')
> > int = f1.read().split('\n')
> >
> > my_vals = intParser(int)
> >
> > intParser return a list
> > f2 = open('myvalues.txt','w')
> > for line in my_vals:
> > f2.write(line)
> > f2.write('\n')
> >
> > f2.close()
> >
> >
> > The problem with this approach is that, i have to
> give
> > on file per a run. I have 50 files to pare and i
> want
> > to do that in one GO. I kepy those 50 files in
> one
> > directory. Can any one suggest an approach to
> automate
> > this process.
> >
> > I tried to use f1 = stdin(...) it did not work. i
> dont
> > know , possible is that i am using incorrect
> syntax.
> >
> > Any suggestions.
> >
> > Thank you.
> > K
> >
> >
> >
> >
> >
> >
> >
> > __________________________________
> > Do you Yahoo!?
> > All your favorites on one personal page � Try My
> Yahoo!
> > http://my.yahoo.com
> > _______________________________________________
> > Tutor maillist - [email protected]
> > http://mail.python.org/mailman/listinfo/tutor
> _______________________________________________
> Tutor maillist - [email protected]
> http://mail.python.org/mailman/listinfo/tutor
>
__________________________________
Do you Yahoo!?
Yahoo! Mail - Find what you need with new enhanced search.
http://info.mail.yahoo.com/mail_250
_______________________________________________
Tutor maillist - [email protected]
http://mail.python.org/mailman/listinfo/tutor