473,320 Members | 1,802 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Re: Combining several files

En Fri, 02 May 2008 17:45:57 -0300, CRAIG DALTON <CX******@sentara.com>
escribió:
I'm looking to append several text files in one director and out put the
combined files into another director. I'm new to Python and just can't
get it to work. So far I've been able to create a file in the desired
directory but it isn't pulling any of the data in the originating
directory. Could please look at my code and tell me what I'm doing wrong.

import os,shutil
f=open("c:\\output\\testing1.txt","a+")
for r,d,fi in os.walk("c:\\test"):
for files in fi:
if files.endswith(".txt"):
g=open(os.path.join(r+,files))
shutil.copyfileobj(g,f)
g.close()
f.close()

Any help would be great.
Except the spurious + in join(r+,files), and the usage of "files" denoting
a single file name, the code looks OK to me. Try adding a few print
statements, showing the files and directories it is processing.

(Note: Next time, if you want to post a NEW question, create a NEW thread
instead of replying to any random post...)

--
Gabriel Genellina

Jun 27 '08 #1
0 971

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Paddy McCarthy | last post by:
Hi, I am trying to use eval as little as possible but solve this problem. #If given:two or more lambda equations x=lambda : A < B y=lambda : C+6 >= 7 .... How do I create another lambda...
0
by: Bob C. | last post by:
I am considering combining one large Access db and several small Access db's into a single SQL Server 2000 db. The small db's serve separate but related functions in our operation, and they all...
2
by: Chris Mullins | last post by:
I've spent a bit of time over the last year trying to implement RFC 3454 (Preparation of Internationalized Strings, aka 'StringPrep'). This RFC is also a dependency for RFC 3491...
3
by: alwayswinter | last post by:
I currently have a form where a user can enter results from a genetic test. I also have a pool of summaries that would correspond to different results that a user would enter into the form. I...
7
by: Barry | last post by:
Hi all, I've noticed a strange error on my website. When I print a capital letter P with a dot above, using & #7766; it appears correctly, but when I use P& #0775 it doesn't. The following...
2
by: Tom_B | last post by:
I need to combine several .wav files into one file, and do this hands-off in an automated environment. Any ideas on how this could be done? What methods or classes are available for reading...
2
by: Stefan | last post by:
Hi there! I'm very new to XML and XSLT, so while working i encountered the following, probably very easy to solve, problem. i've got 2 XML-files, which look like this: LinesOfCode.xml:...
1
by: Ken Fine | last post by:
I am wondering if there is a build-in method in .NET for arbitrarily and correctly combining/concatenating querystring variables into a valid querystring. i.e. I might have the following vars I...
6
by: John Salerno | last post by:
Before I try this and destroy my computer :) I just wanted to see if this would even work at all. Is it possible to read a binary file such as an mp3 or an avi, put its contents into a new file,...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.