MathGroup Archive 2006

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

Search the Archive

Re: Input, output troubles me ...

  • To: mathgroup at smc.vnet.net
  • Subject: [mg70094] Re: Input, output troubles me ...
  • From: Jean-Marc Gulliet <jeanmarc.gulliet at gmail.com>
  • Date: Tue, 3 Oct 2006 06:16:41 -0400 (EDT)
  • Organization: The Open University, Milton Keynes, UK
  • References: <efldl4$d6s$1@smc.vnet.net> <efq5l0$2b0$1@smc.vnet.net>

luigirmailbox-mathematica at yahoo.it wrote:
> Thanks for your quick and useful replies!
> 
> Now it works fine but still a point rimanes to be fixed up.
> As far as I see, Write has no options, so how can I prevent
> Mathematica from enclosing each row of the output file between
> quotes ?
> 
> Best regards.
> 

You can change the format of the expressions either for the whole file 
(see example below) or on an expression basis by enclosing the 
expression with a wrapper function such as, say, TexForm, etc. Section 
2.12.3, "Advanced Topic: Streams and Lowâ??Level Input and Output," of 
/The Mathematica Book/ explains all of these points in details [1].

stream1 = OpenRead["c:\\temp\\inputFile.txt"];
stream2 = OpenWrite["c:\\temp\\outputFile.txt",
     FormatType -> OutputForm];

dummy = Read[stream1, "String"];
While[dummy =!= EndOfFile,
   If[dummy != "a", Write[stream2, dummy]];
    dummy = Read[stream1, "String"]; ]

Close[stream1];
Close[stream2];

Regards,
Jean-Marc

[1] http://documents.wolfram.com/mathematica/book/section-2.12.3


  • Prev by Date: Re: Deriviation
  • Next by Date: Re: tableform question
  • Previous by thread: Re: Re: Input, output troubles me ...
  • Next by thread: Re: distance function