Re: Importing external grid file to do contour plot
- To: mathgroup at smc.vnet.net
- Subject: [mg13047] Re: Importing external grid file to do contour plot
- From: "P.J. Hinton" <paulh>
- Date: Sat, 4 Jul 1998 16:44:51 -0400
- Organization: Wolfram Research, Inc.
- Sender: owner-wri-mathgroup at wolfram.com
On 30 Jun 1998, Sophie Hon wrote: > I'm trying to read an outside grid file into Mathematica in order to do > a contour plot. It's a 50 by 50 grid, so that the data is arranged as > 50 strings of 50 numbers. > Here is what I have so far, which I know does not work: > > ReadList["Macintosh HD:Mathematica 3.0 Files:fish:aqc.grd", > Array[Number,{50,50}]] > > I would appreciate your help very much. Sincerely, How are the individual numbers separated in the file? This is important information to consider when formulating a ReadList[] expression. If you are dealing with space or tab delimited data, then the following command should probably work: ReadList["Macintosh HD:Mathematica 3.0 Files:fish:aqc.grd", Number, RecordLists -> True ] This tells Mathematica to read the contents of the file as a list. By default, spaces and tabs are interpreted by the kernel as separators between numbers. The option RecordLists, when set to true, starts a new row in the List whenever a newline character is encountered. A more detailed discussion of this can be found in the Mathematica book. If you have access to the online documentation, you can evaluate the following expression in a notebook and the HelpBrowser will be opened to the appropriate section: FrontEndExecute[FrontEnd`HelpBrowserLookup["MainBook", "2.11.7"]] If you are dealing with comma delimited data, things are a little more complicated. See the FAQ at URL: http://www.wolfram.com/support/InputOutput/ExternalFiles/CommaSeparatedData.html for a possible solution. -- P.J. Hinton Mathematica Programming Group paulh at wolfram.com Wolfram Research, Inc. http://www.wolfram.com/~paulh/ Disclaimer: Opinions expressed herein are those of the author alone.