Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2004
*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 2004

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

Search the Archive

Re: using file txt in mathematica

  • To: mathgroup at smc.vnet.net
  • Subject: [mg49423] Re: [mg49414] using file txt in mathematica
  • From: Tomas Garza <tgarza01 at prodigy.net.mx>
  • Date: Mon, 19 Jul 2004 07:46:14 -0400 (EDT)
  • References: <200407181209.IAA25949@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

First of all, if you want to save your output a as a text file outside of
Mathematica (presumably to be used by other programas, such as Excel or the
such) you must use the proper syntax. By the way, you have the wrong syntax
for a, too, which I guess should be


In[2]:=
a={{1,2,3,4},{5,6,7,8},{9,10,11,12},{13,14,15,16}}

Then, save this by using

In[5]:=
Export["a.txt", a, "CSV"]

Notice that !!a.txt simply displays the contents of the file a.txt - it
doesn't load a.txt, as you say. In order to bring it back and use it with
the same name a, do

In[9]:=
a  = Import["a.txt", "CSV"]
Out[9]=
{{1, 2, 3, 4}, {5, 6, 7, 8}, {9, 10, 11, 12},
  {13, 14, 15, 16}}

Check the result:

In[11]:=
a
Out[11]=
{{1, 2, 3, 4}, {5, 6, 7, 8}, {9, 10, 11, 12},
  {13, 14, 15, 16}}

Tomas Garza
Mexico City
----- Original Message ----- 
From: "paolo" <tarpanelli at libero.it>
To: mathgroup at smc.vnet.net
Subject: [mg49423] [mg49414] using file txt in mathematica


> If I save an output from a module in a txt file, how can i use it again in
one other module?
> For example:
>
> The output from my module is
>
> a = {1,2,3,4}{5,6,7,8}{9,10,11,12}{13,14,15,16}
>
> save this output is a .txt file format
>
> TextForm @ TableForm[a] >> "a.txt"
>
> then load the file txt
>
> !! a.txt
>
> but how can I use, in one other module, the single elements of matrix "a"
that I saved in the file .txt?? for example how can i do this:
>
> a[[1]][[3]] * y ???????
>
> Thanks and regards
>
> Paolo
>
>



  • Prev by Date: Re: newbie alert: FindRoot
  • Next by Date: Re: importing image and getting numbers from the gray intensity
  • Previous by thread: Re: using file txt in mathematica
  • Next by thread: Re: using file txt in mathematica