[Scilab-users] Matrix of characters conversion

Adrien Vogt-Schilb vogt at centre-cired.fr
Mon Oct 21 15:31:03 CEST 2013


I would read the string matrix, trying to obtain a 1x1 string matrix (or 
at least a 1 column string matri, eg with csvRead)

then use *regexp *to replace several spaces by only one, i guess you 
have to replace " *" by "*" (without the quotes: replace [SPACE][STAR] 
by [SPACE])

then split the matrix where the single spaces are separtors with 
*csvTextScan*



On 21/10/2013 09:02, Carrico, Paul wrote:
>
> Dear Paul
>
> Yes, you're right ...  it can be done easily under vi for example ...  
> but it remains a trick !
>
> Is it out of Scilab scope to directly manage the number of spaces (as 
> separator) ?
>
> Paul
>
> *De :*Paul BIGNIER [mailto:paul.bignier at scilab-enterprises.com]
> *Envoyé :* lundi 21 octobre 2013 14:51
> *À :* International users mailing list for Scilab.; Carrico, Paul
> *Objet :* Re: [Scilab-users] Matrix of characters conversion
>
> Dear Paul,
>
> How about manually editing your file to standardize the spacing 
> between the numbers?
>
> For instance, using your editor's "Find and Replace" tool to replace 
> two spaces "  " with one space " " until you get only one space 
> between each number?
>
> Hope this helps,
> Have a good day,
> Paul.
>
>
> On 10/21/2013 02:29 PM, Carrico, Paul wrote:
>
>     Dear All
>
>     How can I convert a matrix of characters into integers when the
>     separator has different number of spaces ?
>
>     The spaces come probably  from a printf format such as :
>      printf("%10d\n",var)
>
>     I 'm currently using*_csvTextScan_*  and I've some troubles/errors  with*_csvRead_*  ...
>
>     _Example_:
>
>     ! 300006     12799 24678     17504     21558    212801     24680
>     17508     21560 !
>
>     NB:
>
>     -I read first an ascii file
>
>     -I removed some specific lines directly in the matrix
>
>     -Then I'm trying to convert the matrix of characters into a matrix
>     of intergers
>
>     Thanks for any suggestion
>
>     Paul
>
>     #########################################
>
>     PATH_FILE=  get_absolute_file_path("lecture.sce");
>
>     FILE_NAME=  'topology_elem.rad';
>
>       
>
>     stacksize('max');
>
>     M=  mopen(PATH_FILE+  "/"  +  FILE_NAME,'r');
>
>     record=  mgetl(M);
>
>     [nl,nc]  =  size(record);
>
>       
>
>     nbre_elem=  (nl/  3);
>
>     Nodes_char(1:nbre_elem)  =  record(1:3:nl);
>
>       
>
>     /// convert/
>
>     Nodes=  csvTextScan(Nodes_char,"    ");/// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!/
>
>       
>
>     mclose(M)
>
>     --------------------------------------------------------------------------------
>
>       
>
>       
>
>     Le présent mail et ses pièces jointes sont confidentiels et destinés à la personne ou aux personnes visée(s) ci-dessus. Si vous avez reçu cet e-mail par erreur, veuillez contacter immédiatement l'expéditeur et effacer le message de votre système. Toute divulgation, copie ou distribution de cet e-mail est strictement interdite.
>
>       
>
>     This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you have received this email in error, please contact the sender and delete the email from your system. If you are not the named addressee you should not disseminate, distribute or copy this email.
>
>       
>
>       
>
>       
>
>     _______________________________________________
>
>     users mailing list
>
>     users at lists.scilab.org  <mailto:users at lists.scilab.org>
>
>     http://lists.scilab.org/mailman/listinfo/users
>
>       
>
>       
>
>
>
>
> -- 
> Paul BIGNIER
> Scilab Engineer & Xcos Developer
> -----------------------------------------------------------
> Scilab Enterprises
> 143bis rue Yves Le Coz - 78000 Versailles, France
> Phone: +33.1.80.77.04.69
> http://www.scilab-enterprises.com
> --------------------------------------------------------------------------------
>
>
> Le présent mail et ses pièces jointes sont confidentiels et destinés à la personne ou aux personnes visée(s) ci-dessus. Si vous avez reçu cet e-mail par erreur, veuillez contacter immédiatement l'expéditeur et effacer le message de votre système. Toute divulgation, copie ou distribution de cet e-mail est strictement interdite.
>
> This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you have received this email in error, please contact the sender and delete the email from your system. If you are not the named addressee you should not disseminate, distribute or copy this email.
>
>
>
>
> _______________________________________________
> users mailing list
> users at lists.scilab.org
> http://lists.scilab.org/mailman/listinfo/users
>
>


-- 
Adrien Vogt-Schilb
PhD Student (Cired) and Consultant (The World Bank)
1 202 473 79 80

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.scilab.org/pipermail/users/attachments/20131021/ad5995d7/attachment.htm>


More information about the users mailing list