[Scilab-users] How to extract matrix in a huge text file

Orbeman ludo.wag at laposte.net
Wed Aug 22 19:16:52 CEST 2012


I've found a speed method "en bidouillant" with VBScript. In fact, I use some
script for the Moldflow API. I have also program an inverse optimisation
with Moldflow and of course Scilab.

//
function data=lecture_patran(path_file, var)
    
    //suppression des 3 premières lignes d'entête du format natif patran
    str_VBS=['Set oFSO =
CreateObject('+ascii(34)+'Scripting.FileSystemObject'+ascii(34)+')';
             'oFSO.CopyFile '+ascii(34)+path_file+ascii(34)+',
'+ascii(34)+'c:\file_patran_src.ele'+ascii(34);
             'Set file_scr =
oFSO.OpenTextFile('+ascii(34)+'c:\file_patran_src.ele'+ascii(34)+', 1)';
             'Set file_new =
oFSO.OpenTextFile('+ascii(34)+path_file+ascii(34)+', 2)';
             'k = 0';
             'Do Until file_scr.AtEndOfStream';
             '    str_line = file_scr.ReadLine';
             '    if k >=3 then';
             '        file_new.WriteLine str_line';
             '    end if';
             '    k = k +1';
             'Loop';
             'oFSO.DeleteFile
'+ascii(34)+'c:\file_patran_src.ele'+ascii(34)+', True']
    
    fd=mopen('c:\script_lecture_patran.vbs', 'wt')
    mputl(str_VBS, fd)
    mclose(fd)
    
    host('cscript '+ascii(34)+'c:\script_lecture_patran.vbs'+ascii(34))
    
    deletefile('c:\script_lecture_patran.vbs')
    
    //nombre de colonnes à lignes (ordre du tenseur)
    select var
    case 'a' then nj=6
    else nj=1
    end
    
    data=read(path_file, -1, nj)
    
endfunction



--
View this message in context: http://mailinglists.scilab.org/How-to-extract-matrix-in-a-huge-text-file-tp4024708p4024728.html
Sent from the Scilab users - Mailing Lists Archives mailing list archive at Nabble.com.



More information about the users mailing list