Re: Importing text file as machine-precision array
- To: mathgroup at smc.vnet.net
- Subject: [mg118039] Re: Importing text file as machine-precision array
- From: Derek Yates <yatesd at me.com>
- Date: Sat, 9 Apr 2011 17:58:28 -0400 (EDT)
- References: <inpfu3$9as$1@smc.vnet.net>
Here are a couple of ideas possibly related to your question although probably not answering it exactly: ByteCount[RandomReal[{0,1}, {n,m}]] where n and m represent the dimensions of your data. This should give you some idea of the size that the data should take I have noticed in past versions of Mathematica that Import does not automatically create a packed array, whereas many in-built functions such as RandomReal do. (I queried this with Wolfram years ago and they said it was intentional that Import does not create packed arrays. This may have changed in later versions, but I have not tested it). You can attempt to create a packed array using: Developer`ToPackedArray[Import[ ... ]] You might want to test Developer`ToPackedArray[N[Import[ ... ]]] as well. You should test that the conversion to a packed array was successful using Developer`PackedArrayQ as there is no warning if it was not possible to create the packed array. (For example, if you have a vector of Reals except for the zero entries which have 0, ie an Integer, then the conversion will likely fail.) The help in Mathematica goes into more detail about packed arrays.