Re: Gluing file together
- To: mathgroup at smc.vnet.net
- Subject: [mg93599] Re: Gluing file together
- From: Jens-Peer Kuska <kuska at informatik.uni-leipzig.de>
- Date: Mon, 17 Nov 2008 06:17:52 -0500 (EST)
- References: <gfp26u$4e6$1@smc.vnet.net>
Hi,
and
Export["c:/temp/out.txt",
StringJoin @@ (Import[#, "Text"] & /@
FileNames["*.txt", {"c:\\MyTextFiles"}]), "Text"]
??
Sorry I dropped your nice For[] loop ;-)
BTW what does the cat command
cat *.txt > out.txt
??
Regards
Jens
Giacomo De Gerolamo wrote:
> Hello !!
>
> I have some text file to glue together;
> I have been experimenting with following code
> (where xxx is for Lines, Text, Binary ...,)
> for a lot of time but it each and every time it
> mess up the output file (splitting lines and adding
> unwanted characters).
>
> Please, can you explain the reason why ?
>
> SetDirectory[NotebookDirectory[]]
>
> fileList=FileNames["*.txt"];
> fileNumber=Length[fileList];
>
> For[
> file=1,
> file<=fileNUmber,
> file++,
> tmp=Import[fileList[[file]],"xxx"];
> str=OpenAppend["out.txt"];
> Write[str,tmp];
> Close[str];
> ]
>
>
> Giacomo De Gerolamo
> (Italy)
>