MathGroup Archive 2005

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

Search the Archive

Re: Write, Put,..


David Annetts schrieb:
> 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.
> 
Hi Kristjan, Dave and Albert,

thanks a lot for your help.

  Greetings,
Uli


  • Prev by Date: Re: Tilting at Windmills?
  • Next by Date: Re: FileNamesin a loop..
  • Previous by thread: Re: Write, Put,..
  • Next by thread: ((a&&b)||c)==((a||c)&&(b||c))