<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<div class="moz-cite-prefix">Hi Richard<br>
<br>
You read the file, first the header and then the matrix, like
this:<br>
<br>
<pre style="font-family:Monospaced;font-style:normal;font-size:17.0;"><span style="color:rgb(0,0,0);">rtf</span><span style="color:rgb(92,92,92);">=</span><span style="color:rgb(50,185,185);">mopen</span><span style="color:rgb(74,85,219);">(</span><span style="color:rgb(0,0,0);">fname</span><span style="color:rgb(0,0,0);">,</span><span style="color:rgb(188,143,143);">"</span><span style="color:rgb(188,143,143);">r</span><span style="color:rgb(188,143,143);">"</span><span style="color:rgb(74,85,219);">)</span><span style="color:rgb(0,0,0);">;</span>
<span style="color:rgb(50,185,185);"><span style="color:rgb(0,0,0);">headr</span><span style="color:rgb(92,92,92);">=</span>mgetl</span><span style="color:rgb(74,85,219);">(</span><span style="color:rgb(0,0,0);">rtf</span><span style="color:rgb(0,0,0);">,</span><span style="color:rgb(188,143,143);">9</span><span style="color:rgb(74,85,219);">)</span><span style="color:rgb(0,0,0);">;</span> <span style="color:rgb(100,174,100);font-style:italic;">// reads 9-line header</span>
<span style="color:rgb(0,0,0);">coords</span><span style="color:rgb(92,92,92);">=</span><span style="color:rgb(50,185,185);">mfscanf</span><span style="color:rgb(74,85,219);">(</span><span style="color:rgb(92,92,92);">-</span><span style="color:rgb(188,143,143);">1</span><span style="color:rgb(0,0,0);">,</span><span style="color:rgb(0,0,0);">rtf</span><span style="color:rgb(0,0,0);">,</span><span style="color:rgb(188,143,143);">"</span><span style="color:rgb(188,143,143);">%f %f %f\n</span><span style="color:rgb(188,143,143);">"</span><span style="color:rgb(74,85,219);">)</span><span style="color:rgb(0,0,0);">;</span>
<span style="color:rgb(50,185,185);">mclose</span><span style="color:rgb(74,85,219);">(</span><span style="color:rgb(0,0,0);">fname</span><span style="color:rgb(74,85,219);">)</span><span style="color:rgb(0,0,0);">;</span></pre>
<br>
Best regards,<br>
Claus<br>
<br>
On 18-06-2017 23:10, Richard llom wrote:<br>
</div>
<blockquote type="cite"
cite="mid:1497820201592-4036587.post@n3.nabble.com">
<pre wrap="">Hello fellow scilab-users,
I'm writing a script to read and process files, which are constructed as
follows:
<file start>
PCB: 007
ASM: 000
LOT: 00000
FW: 1477971088
CH1: AMPS 10A
CH2: VOLT 60V
SMPL: 0064 0125Hz
DESC: 12V CU LOG
UTC TIME SEC ,CH1 AMPS DC ,CH2 VOLT DC
1497812372.910, 8.609146E-03, 1.210613E001
1497812373.895, 1.577809E-01, 1.207540E001
1497812374.578, 1.010268E000, 1.193087E001
... [snip]
<file end>
To process this file further, I need:
1)
the first eight lines stored in pairs, e.g.
info(1,1) should yield "PCB" and info(1,2) should yield "007" (string is ok)
2)
line #9 (header), should be available as header(1)="UTC TIME SEC", etc...
3)
line 10+
these should be scanned in as a matrix.
I already tried csvread and msscanf (?), however with no luck so far...
So if someone could just point me to the apropiates function for each task.
I hopefully can take it then from there.
Thanks & cheers
richard
--
View this message in context: <a class="moz-txt-link-freetext" href="http://mailinglists.scilab.org/Advice-needed-on-file-parsing-tp4036587.html">http://mailinglists.scilab.org/Advice-needed-on-file-parsing-tp4036587.html</a>
Sent from the Scilab users - Mailing Lists Archives mailing list archive at Nabble.com.
_______________________________________________
users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:users@lists.scilab.org">users@lists.scilab.org</a>
<a class="moz-txt-link-freetext" href="http://lists.scilab.org/mailman/listinfo/users">http://lists.scilab.org/mailman/listinfo/users</a>
</pre>
</blockquote>
<p><br>
</p>
</body>
</html>