Re: comments in import files
- To: mathgroup at smc.vnet.net
- Subject: [mg74640] Re: comments in import files
- From: Bill Rowe <readnewsciv at sbcglobal.net>
- Date: Thu, 29 Mar 2007 02:33:39 -0500 (EST)
On 3/28/07 at 4:36 AM, beheiger at hotmail.com (beheiger) wrote: >I would like to know if Mathematica can handle comments in import >files. In particular, I would like to add lines of comments to an ><emptyspace>-separated ASCII table (say, "results.dat") that I >produced with other programs. However, I can't seem to find anything >on how to write these comments in such a way that Mathematica's >function, used as >Import["results.dat","Table"]; My approach for dealing with this issue is to format the data in a fashion consistent with using the Mathematica Get function. Specifically, I save data from other apps as comma separated values and surround each line with {} characters terminating lines with a ,. Then adding a { at the beginning and a } at the end allows the entire file to be read into a Mathematica variable using Get. With this structure, it is a simple matter to add comments any where in the file separating them with (* and *). Mathematica will ignore these when the file is read using Get. This structure allows me to easily look at the data files with a text editor to see what they contain. In addition, I've created a couple of functions to use within Mathematica that allow me to read just the comments or append comments to any text file. If there is interest, I will post those here. -- To reply via email subtract one hundred and four