Hello all,

Being new to PDL, I was wondering how can I replace non-existant values with 0, while reading them.

Suppose I have the following tab seperated text file (a.txt):

1 0 0.1000 0.1000 0.8000
1 0 0.1000 0.1000 0.2750 0.5250
2 0 0.1000 0.1000 0.8000

then I use the following perl function:


($x, $y, @arr_I) = rcols 'a.txt', { COLSEP => "\t",PERLCOLS => 0 } ;
$x includes the first column and $y includes the second. @arr_I includes colums 3,4,5. However I would like it to include the 6 the column as well with ( 0, 0.5250, 0).

I was wondering if there is any way to do that. Thanks in advance!


In reply to PDL rcols : Replacing missing values with 0 by roark

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.