MathGroup Archive 2001

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

Search the Archive

RE:data files

  • To: mathgroup at smc.vnet.net
  • Subject: [mg31191] RE:[mg31164] data files
  • From: "Helge Andersson" <helgea at inoc.chalmers.se>
  • Date: Wed, 17 Oct 2001 05:35:13 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

Tim wrote: 2001-10-14 10:12

I wish to plot data stored as a matrix in a text file.  I also want to
be able to output data into a file.  How can I achieve this ?

Thanks

Tim
__________________
Hello Tim,

Here are functions that you can use for reading and storing
2-dimensional data.

ListToSpreadsheet[path_String,data_List]:=Module[
    {strm=OpenWrite[path],len=Length[data]},
    WriteString[strm,
    StringReplace[
     ToString[
 
FortranForm/@data[[#]]],{","->"\t","{"->"","}"->""}]<>"\n"]&/@Range[len]
;
    Close[strm]
     ]

SpreadsheetToList[path_String]:=ReadList[path,Number,RecordLists->True];

If you want to delete the headers from the original spreadsheet you can
delete the first line like this:

SpreadsheetToList2[path_String]:=Delete[ReadList[path,Word,RecordLists->
True,RecordSeparators->{"\n"}],1];

/Helge

Fil Dr. Helge Andersson
Oorganisk miljökemi
CHALMERS
SE-412 96 Göteborg




  • Prev by Date: Limit and Abs
  • Next by Date: Front End, GUI for Application
  • Previous by thread: Re: MultiProcessor Kernel.
  • Next by thread: Plotting unfilled bars in GeneralizedBarChart