Re: Export, Import, Convert Types Again?
- To: mathgroup at smc.vnet.net
- Subject: [mg57220] Re: Export, Import, Convert Types Again?
- From: Gareth Russell <gjr2008 at columbia.edu>
- Date: Sat, 21 May 2005 02:39:37 -0400 (EDT)
- Organization: Columbia University
- References: <d6k9ev$10q$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Lee, Usually it suffices to map ToExpression[] over the data you re-imported -- it should recognize the lists as lists, and so on. What you are experiencing is not a bug -- you say yourself that you want to view the exported data in a text editor, so you export using a function which drops all the Mathematica 'baggage' such as heads. Gareth On 2005-05-20 05:08:47 -0400, Lee Newman <leenewm at umich.edu> said: > Q: What is the (best) way to save a big expression of data to be used > later in the same notebook without having to do type conversion > processing? > > Situation: > > 1) I have a notebook that imports data from various Excel spreadsheets > and converts the data to the desired types. When complete, I "save" > the expression containing the data using Export, i.e, > Export["featureDB.tsv", "TSV"]. I do this so I don't have to > re-process the data everytime I do analysis on it in this notebook. > > 2) When I open the noteobook again, I import the data using the > statement: featureDB = Import["featureDB.tsv"] > > Problem: > Many of type conversions that I took the time to process are lost. > Using Head /@ featureDB[[1]] before and after the export/re-import, > the types are as follows: > > Before: {Integer, Integer, List, List, List, Integer, List, List, > Symbol, List} > After : {Integer, Integer, String, String, String, Integer, String, > String, String, String} > > So it seems that lists become Strings as Symbols (e.g. True, False, > Null). I use Export so I can view the data outside Mathematica using a > text editor -- should I use Save instead? Is there another Export > format that will preserve mathematica expressions like lists upon > Import? > > Thanks, > Lee