MathGroup Archive 2011

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

Search the Archive

Re: Improt vs Get

  • To: mathgroup at smc.vnet.net
  • Subject: [mg119930] Re: Improt vs Get
  • From: "Scot T. Martin" <smartin at seas.harvard.edu>
  • Date: Thu, 30 Jun 2011 06:30:28 -0400 (EDT)
  • References: <201106250929.FAA20235@smc.vnet.net>

Ted,


Import[...,"List"] (as well as "CSV" and "Table") features some automatic translation of common numbers used by other languages. These include "E" used by many programs as well as "D" from Fortran, etc.


Get[...], by contrast, does a literal import. Your literal import in FullForm is:
In[3]:= FullForm[Hold[-0.5066E+01]]

Out[3]//FullForm= Hold[Plus[Times[-0.5066`,E],1]]

This is where the number -0.377082 comes from.


In summary, use Get[...] rarely and only for stuff generated and saved with in Mathematica, such as by DumpSave[...], packages, etc.

Use Import[...] for stuff made outside of Mathematica that you are importing into Mathematica.

Scot

________________________________________
From: Ted Sariyski [tsariysk at craft-tech.com]
Sent: Wednesday, June 29, 2011 05:29
To: mathgroup at smc.vnet.net
Subject: [mg119930] Improt vs Get

Hi,
I have a file tst:

{{X [m], -0.5066E+01, -0.4039E+01, -0.3012E+01},{Y [m], -0.5066E+01,
-0.4039E+01, -0.3012E+01}}

which I Get:
fn = FileNameJoin[{myDir, "tst"}]

In[]= Get[fn]
Out[]=
{{X[m],-0.377082,-0.097914,0.181254},{Y[m],-0.377082,-0.097914,0.181254}}

which is not what I expect.

Import, however, returns the content of tst:

In[] =Import[fn,"List"]
Out[]= {{{X [m], -0.5066E+01, -0.4039E+01, -0.3012E+01},{Y [m],
-0.5066E+01, -0.4039E+01, -0.3012E+01}}}

What do I miss here?
Thanks in advance,
--Ted


  • Prev by Date: Re: How to find the difference between two lists (opposite of union[]?)
  • Next by Date: Extract values from optimized solution
  • Previous by thread: Re: Improt vs Get
  • Next by thread: Re: Improt vs Get