Maybe someone can help with this. I have a function that takes a
single file as an argument and outputs a tuple with each line of the
file as a string element. This is part of a script that is intended
to concatenate lines in files, and output them to a different file.
This is as far as I've
On Tue, Mar 1, 2011 at 11:55 AM, Sean Carolan scaro...@gmail.com wrote:
Maybe someone can help with this. I have a function that takes a
single file as an argument and outputs a tuple with each line of the
file as a string element. This is part of a script that is intended
to concatenate
Sean,
: Maybe someone can help with this. I have a function that takes a
: single file as an argument and outputs a tuple with each line of
: the file as a string element. This is part of a script that is
: intended to concatenate lines in files, and output them to a
: different file.
On Tue, Mar 1, 2011 at 7:10 PM, Sean Carolan scaro...@gmail.com wrote:
On Tue, Mar 1, 2011 at 11:55 AM, Sean Carolan scaro...@gmail.com wrote:
Maybe someone can help with this. I have a function that takes a
single file as an argument and outputs a tuple with each line of the
file as a string
I saw in your follow-up that you went straight for vars(). I really
don't think that's what you wish to use. Get rid of vars(), he had
to go to jail. Don't go visit vars() again for at least two months,
then maybe he'll be out on probation.
Thanks Martin and Hugo. As you can tell I'm no
On Tue, Mar 1, 2011 at 1:59 PM, Sean Carolan scaro...@gmail.com wrote:
I saw in your follow-up that you went straight for vars(). I really
don't think that's what you wish to use. Get rid of vars(), he had
to go to jail. Don't go visit vars() again for at least two months,
then maybe
On 3/1/2011 10:59 AM Sean Carolan said...
Take an arbitrary number of text files. Assume that each text file has
the exact same number of lines. Concatenate each line of each file
with the corresponding lines of the other files and output the data.
So in other words, the first line of output
On Tue, Mar 1, 2011 at 7:59 PM, Sean Carolan scaro...@gmail.com wrote:
I saw in your follow-up that you went straight for vars(). I really
don't think that's what you wish to use. Get rid of vars(), he had
to go to jail. Don't go visit vars() again for at least two months,
then maybe he'll
My advice would be to go read up on the zip() function and the
str.join() function. Then, if you are using python 2.x, go find
itertools.izip. It does the same thing as zip but it's more memory
efficient. With those two you can do it in about two lines or so (and
maybe a few for set up and
On 3/1/2011 11:49 AM Sean Carolan said...
My advice would be to go read up on the zip() function and the
str.join() function. Then, if you are using python 2.x, go find
itertools.izip. It does the same thing as zip but it's more memory
efficient. With those two you can do it in about two lines
Emile van Sebille wrote:
On 3/1/2011 11:49 AM Sean Carolan said...
My advice would be to go read up on the zip() function and the
str.join() function. Then, if you are using python 2.x, go find
itertools.izip. It does the same thing as zip but it's more memory
efficient. With those two you can
Another way is:
zip(*map(open, myfiles))
Then your loop looks like:
for i in zip([ cleanedup(filename) for filename in myfiles ])
Thanks, Steven! I knew there was a way to do this with just a few
lines. I will read up some more on list expansion and the map
built-in.
12 matches
Mail list logo