Pyhton script to call another program

2009-05-06 Thread Ben Keshet
Hi, I am trying to write a simple python script to manipulate files and call other programs. I have a program installed (rocs) which I run using cygwin on my XP (but is not in python). Can I run the pyhton script and then call the other program in the same script? For example: Python Code

manipulating files within 'for'

2008-09-12 Thread Ben Keshet
Hi Pythoneers, I have a question about a code I wrote with the help of someone. The code below copy a few lines from different files into one file. It works fine as it is given here and generates the new file 'pockets.out' correctly, but says:py returned exit code 0. However, if I add

Re: manipulating files within 'for'

2008-09-12 Thread Ben Keshet
Emile van Sebille wrote: Ben Keshet wrote: Hi Pythoneers, I have a question about a code I wrote with the help of someone. The code below copy a few lines from different files into one file. It works fine as it is given here and generates the new file 'pockets.out' correctly, but says

Re: 'While' question

2008-08-23 Thread Ben Keshet
Wojtek Walczak wrote: On Fri, 22 Aug 2008 10:42:13 -0400, Ben Keshet wrote: Thanks. I tried to use 'for' instead of 'while' as both of you suggested. It's running well as my previous version but breaks completely instead of just skipping the empty file. I suspect the reason

Re: 'While' question

2008-08-22 Thread Ben Keshet
Thanks. I tried to use 'for' instead of 'while' as both of you suggested. It's running well as my previous version but breaks completely instead of just skipping the empty file. I suspect the reason is that this part is inside another 'for' so it stops everything. I just want to it to

'While' question

2008-08-21 Thread Ben Keshet
Hi - I am writing now my second script ever in python and need some help with 'while'. I am reading text from a set of files and manipulating the data somehow. I use 'while 'word' not in line' to recognize words in the texts. Sometimes, the files are empty, so while doesn't find 'word' and

Re: 'While' question

2008-08-21 Thread Ben Keshet
: On Thu, 21 Aug 2008 18:01:25 -0400, Ben Keshet wrote: somehow. I use 'while 'word' not in line' to recognize words in the texts. Sometimes, the files are empty, so while doesn't find 'word' and runs forever. I have two questions: 1) how do I overcome this, and make the script skip the empty files

Re: a simple 'for' question

2008-07-09 Thread Ben Keshet
# print the current folder filename='Folder/%s/myfile.txt' %[x] f=open(filename,'r') gives: IOError: [Errno 2] No such file or directory: Folder/['1']/myfile.txt Tim Cook wrote: On Wed, 2008-07-09 at 00:00 -0400, Ben Keshet wrote: oops, my mistake, actually it didn't work... when I

a simple 'for' question

2008-07-08 Thread Ben Keshet
Hi fans, I want to use a 'for' iteration to manipulate files in a set of folders, something like: folders= ['1A28','1A6W','56Y7'] for x in folders: print x # print the current folder f = open('my/path/way/x/my_file.txt', 'r') ... where 'x' in the pathway should iterate over

Re: a simple 'for' question

2008-07-08 Thread Ben Keshet
right or using the right terms as I am fairly new to programing and python. Thanks for your time. Ben Brian Blais wrote: On Jul 8, 2008, at Jul 8:8:08 PM, Ben Keshet wrote: I want to use a 'for' iteration to manipulate files in a set of folders, something like: folders= ['1A28','1A6W

Re: a simple 'for' question

2008-07-08 Thread Ben Keshet
Brian Blais wrote: On Jul 8, 2008, at Jul 8:8:08 PM, Ben Keshet wrote: I want to use a 'for' iteration to manipulate files in a set of folders, something like: folders= ['1A28','1A6W','56Y7'] for x in folders: print x # print the current folder f = open('my/path/way/x/my_file.txt', 'r

Write a file - beginner's question

2008-07-03 Thread Ben Keshet
I have a probably simple beginner's question - I have a script that I am currently able to print its output. instead, i want to write it into a file - I tried different versions of write() but might have gotten the syntax wrong. the variable I want to write is a line from a file I am

beginner's questions - manipulating text files

2008-07-01 Thread Ben Keshet
Hi, I am a very beginner Python programmer with limited programming experience overall. I am trying to write a script that will search for the second and third appearance of the symbol '@' in a file, will read a random line between them, and write the line into a new file. So far I was only