MathGroup Archive 2008

[Date Index] [Thread Index] [Author Index]

Search the Archive

RE: Gluing file together

  • To: mathgroup at smc.vnet.net
  • Subject: [mg93595] RE: [mg93585] Gluing file together
  • From: "David Annetts" <davidannetts at aapt.net.au>
  • Date: Mon, 17 Nov 2008 06:17:08 -0500 (EST)
  • References: <200811161203.HAA04554@smc.vnet.net>

Hi Giacomo,
> 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];
> ]

The first thing to ask your self is why you're appending each iteration.

 str=OpenAppend["out.txt"];
 For[
    file=1,
    file<=fileNUmber,
    file++,
      tmp=Import[fileList[[file]],"xxx"];
      Write[str,tmp];
 ]
 Close[str];

is probably more like what you're after.

Regards,

Dave.




  • Prev by Date: Re: Machine-precision Exp[] function
  • Next by Date: Re: Gluing file together
  • Previous by thread: Gluing file together
  • Next by thread: Re: Gluing file together