<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, Feb 20, 2013 at 11:26 AM, Roland Koebler <span dir="ltr"><<a href="mailto:r.koebler@yahoo.de" target="_blank">r.koebler@yahoo.de</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
<div class="im"><br>
On Wed, Feb 20, 2013 at 10:50:54AM +0100, inshu chauhan wrote:<br>
> I have 10 simple text files with 3 columns x,y,z delimited by "space". I am<br>
> trying to combine these 10 files to get a single text file.<br>
><br>
> Eg. of data in 10 files is<br>
> 299 446 2<br>
</div>Do you only want to concat the files, or do you want to parse/mangle<br>
them?<br>
<br>
If you only want to concat the files, I would use some shell-tools,<br>
like "cat" on Linux or "copy" on Windows, so<br>
<br>
copy C:\Users\inshu.chauhan\Desktop\ForModel_600\*.arff C:\Users\inshu.chauhan\Desktop\test2.arff<br>
<br>
should do it.<br>
<div class="im"><br>
> Can in some some way I set delimiter to NULL as the prog gives me error if<br>
> I do so.<br>
</div>Of course -- a CSV without a delimiter doesn't make any sense.<br>
<div class="im"><br>
> I dont why there is space between the attribute of first column in<br>
> reading and there is space between every row too..<br>
</div>Because there's a "split()" missing in your code. You currently tell the<br>
CSV-writer to write the columns 2,9,9, , , ,4,4,6, , , ,2 as<br>
space-separated CSV. So, try something like<br>
rows = [r.split() for r in open(f, "r").readlines()]<br>
<div class="im"><br>
> Or can I merge these text files without using csv module , directly in<br>
> python ?<br>
</div>If you don't need to parse/mangle the contents, you don't need the csv<br>
module. Simple open the resulting file for writing, and then read out<br>
the source files and write their contents into the resulting file.<br>
<br>
<span class="HOEnZb"><font color="#888888"><br></font></span></blockquote><div>Yes I just want to concat the files , not parse/mangle the files. How can i simply read all files in a folder in my computer and write them into a single file ? just by 'printf ' is it possible ? <br>
<br></div></div><br></div></div>