Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
1998
*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 1998

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

Search the Archive

Re: Outputting Strings to a file

  • To: mathgroup at smc.vnet.net
  • Subject: [mg14189] Re: [mg14175] Outputting Strings to a file
  • From: David Withoff <withoff>
  • Date: Wed, 30 Sep 1998 19:42:22 -0400
  • Sender: owner-wri-mathgroup at wolfram.com

> I am trying to output text to a file.  My data is in an array such as:
>
> {1,"AL",0.500000,0.500000,0.500000,0.300000,1.000000}
>
> or
>
> {"Line One","Line Two"}
>
> The program that is going to read the output file doesn't want the
> quotes or the commas.
>
> I want the final file to look like:
>
> Line One
> Line Two
> 1 Al 0.500000 0.500000 0.500000 0.300000 1.000000
>
> How do I get Mathematica to output text without the quotes?  If I can
> get that I'm pretty sure I can get the numbers and spacing correct.
>
> I'm running Mathmatica 3.0 on a powermac if that is important.
>
> Thanks for any help.
>
> --
> Tom Murray
>
>      I believe in what I see
>      I believe in what I hear
>      I believe that what I'm feeling
>      Changes how the world appears
>
>      Rush - "TOTEM" - Test For Echo

Here is one possibility.  I expect that some variant of this, or other
formatting functions, will do what you want.

In[6]:= expr = {1,"AL",0.500000,0.500000,0.500000,0.300000,1.000000}

Out[6]= {1, AL, 0.5, 0.5, 0.5, 0.3, 1.}

In[7]:= Infix[expr /. p_Real -> PaddedForm[p, {7, 6}], " "]

Out[7]= 1 AL  0.500000  0.500000  0.500000  0.300000  1.000000

In[8]:= Write["file", OutputForm[
            Infix[expr /. p_Real -> PaddedForm[p, {7, 6}], " "] ]
        ]

In[9]:= !!file
1 AL  0.500000  0.500000  0.500000  0.300000  1.000000

If you can get what you want formatted on the screen (probably in
OutputForm), then you can write it to a file, as the same functionality
is used for both purposes.

Dave Withoff
Wolfram Research


  • Prev by Date: Re: Help with evaluation of infinite summation
  • Next by Date: Printing 3d plots under Win95
  • Previous by thread: Outputting Strings to a file
  • Next by thread: Free Rubiks cube package