<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=gb2312">
<META content="MSHTML 6.00.6000.16825" name=GENERATOR>
<STYLE>@font-face {
font-family: 宋体;
}
@font-face {
font-family: Verdana;
}
@font-face {
font-family: @宋体;
}
@page Section1 {size: 595.3pt 841.9pt; margin: 72.0pt 90.0pt 72.0pt 90.0pt; layout-grid: 15.6pt; }
P.MsoNormal {
TEXT-JUSTIFY: inter-ideograph; FONT-SIZE: 10.5pt; MARGIN: 0cm 0cm 0pt; FONT-FAMILY: "Times New Roman"; TEXT-ALIGN: justify
}
LI.MsoNormal {
TEXT-JUSTIFY: inter-ideograph; FONT-SIZE: 10.5pt; MARGIN: 0cm 0cm 0pt; FONT-FAMILY: "Times New Roman"; TEXT-ALIGN: justify
}
DIV.MsoNormal {
TEXT-JUSTIFY: inter-ideograph; FONT-SIZE: 10.5pt; MARGIN: 0cm 0cm 0pt; FONT-FAMILY: "Times New Roman"; TEXT-ALIGN: justify
}
A:link {
COLOR: blue; TEXT-DECORATION: underline
}
SPAN.MsoHyperlink {
COLOR: blue; TEXT-DECORATION: underline
}
A:visited {
COLOR: purple; TEXT-DECORATION: underline
}
SPAN.MsoHyperlinkFollowed {
COLOR: purple; TEXT-DECORATION: underline
}
SPAN.EmailStyle17 {
FONT-WEIGHT: normal; COLOR: windowtext; FONT-STYLE: normal; FONT-FAMILY: Verdana; TEXT-DECORATION: none; mso-style-type: personal-compose
}
DIV.Section1 {
page: Section1
}
UNKNOWN {
FONT-SIZE: 10pt
}
BLOCKQUOTE {
MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px; MARGIN-LEFT: 2em
}
OL {
MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px
}
UL {
MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px
}
</STYLE>
</HEAD>
<BODY style="FONT-SIZE: 10pt; FONT-FAMILY: verdana">
<DIV><FONT face=Verdana color=#000080 size=2>Hi Hari,</FONT></DIV>
<DIV><FONT color=#000080>Thanks much for your support. Attached is my reply to
</FONT><FONT color=#000000>Prof. Ramachandran. Hope it could give you
another perspective. </FONT></DIV>
<DIV><FONT color=#000000>Best, </FONT></DIV>
<DIV><FONT color=#000000>Zhiming</FONT></DIV>
<DIV><FONT face=Verdana color=#000080 size=2></FONT> </DIV>
<DIV><FONT color=#000080>
<DIV><FONT face=Verdana color=#000080 size=2>Dear Dr. <FONT
color=#000000>Ramachandran,</FONT></FONT></DIV>
<DIV> </DIV>
<DIV>Thank you very much! That's exactly what I want. The main problem is that I
only know read('filename.txt', m, n) statement, and it could not work for data
mixed with characters. I tried a lot and never find read statemtne like
A=read("data.txt",-1,1,"(a)"). It helps a lot.</DIV>
<DIV> </DIV>
<DIV>I kind of solved this problem by using file statement:</DIV>
<DIV> </DIV>
<DIV>A =[]; B=[]; C=[];<BR>v=file('open', 'data.txt', 'old');<BR>for i =
1:36000<BR> if i<=12 then Head=fscanf(v,
'%s'); // there is 12
headlines;<BR> else [AA BB CC]=fscanf(v, '%f %f
%f');<BR> A=[A; AA]; B=[B; BB]; C=[C;
CC];<BR>end<BR>end</DIV>
<DIV><FONT face=Verdana color=#000080 size=2>// the data I want is</FONT></DIV>
<DIV><FONT face=Verdana color=#000080 size=2> [A, B, C]</FONT></DIV>
<DIV><FONT face=Verdana color=#000080 size=2></FONT> </DIV>
<DIV><FONT color=#000080>Your read statement is so good that I do not have to
write so long a program. I really appreciate your help.</FONT></DIV>
<DIV><FONT color=#000080>Thanks much and have a great day,</FONT></DIV>
<DIV><FONT color=#000080></FONT> </DIV>
<DIV><FONT color=#000080>Zhiming</FONT></DIV>
<DIV><FONT color=#000080>Iowa State University</FONT></DIV>
<DIV><FONT color=#000080>Agricultural Engineering
Department</FONT></DIV></FONT></DIV>
<DIV><FONT color=#000080></FONT> </DIV>
<DIV><FONT color=#000080></FONT> </DIV>
<DIV><FONT color=#000080></FONT> </DIV>
<DIV><FONT color=#000080></FONT> </DIV>
<DIV><FONT face=Verdana color=#000080 size=2></FONT> </DIV>
<DIV><FONT face=Verdana color=#c0c0c0 size=2>2009-05-12 </FONT></DIV><FONT
face=Verdana color=#000080 size=2>
<HR style="WIDTH: 122px; HEIGHT: 2px" align=left SIZE=2>
</FONT>
<DIV><FONT face=Verdana color=#c0c0c0 size=2><SPAN>isuzman</SPAN>
</FONT></DIV><FONT face=Verdana color=#000080 size=2>
<HR>
</FONT>
<DIV><FONT face=Verdana size=2><STRONG>发件人:</STRONG> Giri </FONT></DIV>
<DIV><FONT face=Verdana size=2><STRONG>发送时间:</STRONG> 2009-05-08 09:32:31
</FONT></DIV>
<DIV><FONT face=Verdana size=2><STRONG>收件人:</STRONG> users@lists.scilab.org
</FONT></DIV>
<DIV><FONT face=Verdana size=2><STRONG>抄送:</STRONG> </FONT></DIV>
<DIV><FONT face=Verdana size=2><STRONG>主题:</STRONG> Re: [scilab-Users] Help in
reading txt file: how to skip the title </FONT></DIV>
<DIV><FONT face=Verdana size=2></FONT> </DIV>
<DIV><FONT face=Verdana size=2>
<DIV>harishankar ramachandran wrote:</DIV>
<DIV> </DIV>
<DIV>> The following program does the specific job:</DIV>
<DIV>></DIV>
<DIV>> // to read in a data file containing header lines starting with</DIV>
<DIV>> // "*" and to read in the columns after the last header line.</DIV>
<DIV>> A=read("data.txt",-1,1,"(a)"); // read in the file</DIV>
<DIV>> jj=grep(A,"*"); // find lines containing "*"</DIV>
<DIV>></DIV>
<DIV>> // We want to skip upto all lines containing "*" So start after</DIV>
<DIV>> // the last such line</DIV>
<DIV>> ibeg=jj(length(jj))+1;</DIV>
<DIV>> iend=size(A,"r");</DIV>
<DIV>> m=iend-ibeg+1;</DIV>
<DIV>> [n,v1,v2,v3]=msscanf(m,A(ibeg:iend),"%f %f %f");</DIV>
<DIV>></DIV>
<DIV>> clf</DIV>
<DIV>> subplot(3,1,1);</DIV>
<DIV>> plot2d(1:m,v1');</DIV>
<DIV>> subplot(3,1,2);</DIV>
<DIV>> plot2d(1:m,v2');</DIV>
<DIV>> subplot(3,1,3);</DIV>
<DIV>> plot2d(1:m,v3');</DIV>
<DIV>></DIV>
<DIV>> // Note that this script hardcoded the number of columns and does</DIV>
<DIV>> // no error checking. Since column information is present in the</DIV>
<DIV>> // file, one could also extract that info and construct the</DIV>
<DIV>> // format string appropriately. Or use the logic in fscanfMat to directly</DIV>
<DIV>> // figure out the number of columns.</DIV>
<DIV>></DIV>
<DIV>> Not sure this is quite what you wanted.</DIV>
<DIV>></DIV>
<DIV>> regards</DIV>
<DIV>></DIV>
<DIV>> hari ramachandran</DIV>
<DIV>></DIV>
<DIV>> On Wednesday 06 May 2009 21:49, Zhiming Qi wrote:</DIV>
<DIV>> > *****************************</DIV>
<DIV>> > * Subplot Definitions *</DIV>
<DIV>> > *****************************</DIV>
<DIV>> > 1</DIV>
<DIV>> > *****************************</DIV>
<DIV>> > * COLUMN LABELS *</DIV>
<DIV>> > *****************************</DIV>
<DIV>> > DAY</DIV>
<DIV>> > DEPTH (CM)</DIV>
<DIV>> > SOIL WATER CONTENT (VOL)</DIV>
<DIV>>
> ****************** DATA STARTS HERE *****************</DIV>
<DIV>> > 274 1.000 0.2898</DIV>
<DIV>> > 274 2.000 0.2919</DIV>
<DIV>> > 274 4.000 0.2939</DIV>
<DIV>> > 274 7.000 0.2990</DIV>
<DIV>> > 274 10.00 0.3035</DIV>
<DIV>> > 274 13.00 0.3130</DIV>
<DIV>> > 274 16.00 0.3172</DIV>
<DIV>> > 274 20.00 0.3201</DIV>
<DIV>> > 274 24.00 0.3243</DIV>
<DIV>> > 274 27.00 0.3272</DIV>
<DIV>> > 274 30.00 0.3300</DIV>
<DIV>> > 274 33.00 0.3210</DIV>
<DIV>> > 274 36.00 0.3223</DIV>
<DIV>> > 274 40.00 0.3236</DIV>
<DIV>> > 274 44.00 0.3258</DIV>
<DIV>> > 274 48.00 0.3273</DIV>
<DIV>> > 274 53.00 0.3302</DIV>
<DIV>> > 274 57.00 0.3345</DIV>
<DIV>> > 274 60.00 0.3381</DIV>
<DIV>> > 274 63.00 0.3331</DIV>
<DIV>></DIV>
<DIV>> --</DIV>
<DIV>> Dr. Hari Ramachandran, Professor, 332B ESB, EE Dept, IIT-Madras</DIV>
<DIV>> Interests: Nonlinear Optics, Nonlinear Waves, Plasma Physics, Particle</DIV>
<DIV>> Simulations, Computational Algorithms, Linux.</DIV>
<DIV>> Off: 91-44-2257-4421 Fax: 91-44-2257-0120</DIV>
<DIV>> Res: 91-44-2663-1863 Home Email: omkarbharathi@gmail.com</DIV>
<DIV> </DIV>
<DIV>Dear Prof. Ramachandran:</DIV>
<DIV>Thanks for the detailed solution, this is a common problem faced</DIV>
<DIV>by anyone trying process data obtained from lab instruments. I was</DIV>
<DIV>also planning to post some similar question as I am new user of</DIV>
<DIV>Scilab. Thanks to Mr Qi also!</DIV>
<DIV>Sincerely,</DIV>
<DIV>Giridhar</DIV>
<DIV> </DIV>
<DIV>--</DIV>
<DIV>M. S. Giridhar</DIV>
<DIV>Thinfilms and Microsensors Group</DIV>
<DIV>Laboratory for Electro Optic Systems</DIV>
<DIV>Indian Space Research Organisation</DIV>
<DIV>1st Cross, 1st Stage, Peenya Industrial Estate,</DIV>
<DIV>Bangalore 560058.</DIV>
<DIV>Phone:2839 2294, 2839 2291 ext 2212</DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV>----------------------------------------------------------------</DIV>
<DIV>This mail contains PRIVILEGED AND CONFIDENTIAL INFORMATION intended solely for the use of the addressee(s). If you are not the intended recipient, please notify the sender by e-mail and delete the original message. LEOS has taken every reasonable precaution to remove any viruses however you should also carry out your own virus checks before opening the e-mail or attachment. </DIV>
<DIV> </DIV>
<DIV> </DIV></FONT></DIV></BODY></HTML>