Re: How to read a data file in text format?_from a new learner
- To: mathgroup at smc.vnet.net
- Subject: [mg62360] Re: How to read a data file in text format?_from a new learner
- From: lucb at ea.com
- Date: Tue, 22 Nov 2005 04:42:01 -0500 (EST)
- Sender: owner-wri-mathgroup at wolfram.com
my pattern for reading files like these would be:
thisFile = OpenRead["C:\\Documents and Settings\\Luc\\Desktop\\sample.txt"];
data = ReadList[thisFile, String];
Close[thisFile];
Then you need to remove the first line:
data2 = Rest[data];
Then transform the strings into proper numbers:
data3 = ToExpression[StringReplace[#, {"," -> "", " " -> ""}]] & /@ data2
Finally plot the data:
ListPlot[data3, PlotRange -> All]
Link to the forum page for this post:
http://www.mathematica-users.org/webMathematica/wiki/wiki.jsp?pageName=Special:Forum_ViewTopic&pid=6189#p6189
Posted through http://www.mathematica-users.org [[postId=6189]]