Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2005
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2005

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

Search the Archive

Re: Write, Put,..

  • To: mathgroup at smc.vnet.net
  • Subject: [mg62050] Re: [mg62010] Write, Put,..
  • From: "David Annetts" <davidannetts at aapt.net.au>
  • Date: Thu, 10 Nov 2005 02:50:32 -0500 (EST)
  • Sender: owner-wri-mathgroup at wolfram.com

Hi Uli, 

> I used Export to get my data into a file. But now I would 
> like to write text and arrays of numbers in a more direct way.
> My problem is that everytime I call e.g. PutAppend or 
> WriteAppend Mathematica starts a new line. Is it not possible 
> to control the output to a file in the same way like with 
> outstream in C++??
> I mean, e.g. to output an element of an array, and then a tab 
> and then maybe a word,...

One way is to write your data to a string, then write the string to your
file.  For example,

Generate some data:-

	data = Random[] & /@ Range[25]

Convert them to a string with special formatting:-

	str = StringJoin[ToString[FromCharacterCode[64 + #]], " = ",
ToString[data[[#]]], "\t"] & /@ Range[Length@data]

And write them to a file:-

	outu = OpenWrite["temp.txt"];
	SetOptions[outu, PageWidth -> Infinity];
	(
      	Write[outu, OutputForm[str]];
      ) & /@ Range[5]
	Close[outu];

Regards,

Dave.


  • Prev by Date: Re: feature request: invert plot axes
  • Next by Date: Re: feature request: invert plot axes
  • Previous by thread: Re: Write, Put,..
  • Next by thread: Re: Write, Put,..