<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <div class="moz-cite-prefix">Hi<br>
      <br>
      The code you provide does not run on my sci 5.5.0<br>
      <br>
      anyway, i would read only the once the matrix, as a string, and
      then use csvTextScan on <br>
      <pre wrap="">mydat(:,2:6)</pre>
      to convert that part to double. Taht already saves time.<br>
      <br>
      in your loop i believe strtod is extremely slow. Again, use
      csvtextscan instead.<br>
      <br>
      Hope this helps<br>
      <br>
      Adrien<br>
      <br>
      On 20/05/2014 14:44, Richard Llom wrote:<br>
    </div>
    <blockquote cite="mid:llg7qj$lr1$1@ger.gmane.org" type="cite">
      <pre wrap="">Hello,
I need to read in a csv of about 360.000 lines with date and numerical 
values. Attached is a sample excerpt of that file.

So far I did:
==== CODE ====

// read in
tic
mydat = csvRead('dat04-2011.csv', ';', ',', 'double', [], [], [], 6);
toc (= 5,213 secs)
mydat = mydat(:,2:6);
tic
mystring = csvRead('dat04-2011.csv', ';', ',', 'string', [], [], [], 6);
toc (= 3,077 secs)
mystring = mystring(:,1);


tic
for i=1:size(mydat,1)
    mydate(i,:) = strtod(strsplit(mystring(i,1),['.';' ';':']))';
end
toc (= 186,473 secs)


==== CODE ====
(I filled in the toc values).


As you can see this is unfortunately very slow. The read in of the csv, but 
especially the for loop.

So I have several question:

1)
Is there a faster way to read in the csv? Note that I need the 'header' 
option.

2)
Instead of the loop I would like to use
mydate = strtod(strsplit(mystring(:,1),['.';' ';':']))';
but this doesn't work. Is there another way to avoid the loop?

3)
The raw csv file is around 15MB, but when I want to read it in the second 
time, Scilab says this will exceed the stacksize. Which is default by 76MB. 
So I don't quite understand how two times the 15MB file takes so much 
memory? I raised the stacksize now, but I would rather like not to.


Any help is appreciated.
Thanks!
Richard</pre>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <pre wrap="">_______________________________________________
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>
    <br>
    <br>
    <pre class="moz-signature" cols="72">-- 
Adrien Vogt-Schilb
Consultant (World Bank) and PhD Candidate (Cired)
1 202 473 7980</pre>
  </body>
</html>