Re: Tab-Delimited Files [message #9034] |
Thu, 22 May 1997 00:00 |
rkj
Messages: 66 Registered: February 1996
|
Member |
|
|
Stephen Ritcey (sritcey@is.dal.ca) wrote:
: R. Kyle Justice (rkj@dukebar.crml.uab.edu) wrote:
: : Is there a way to create tab-delimted files in
: : PV-Wave?
: : I have columns of data and I would like to
: : separate them by tabs instead of spaces. I
: : can't seem to get it to work with Fortran
: : or C format codes in DC_WRITE_FIXED.
: The following works for me...
: tab = string (9B)
: column1 = [ 1, 2, 3, 4]
: column2 = [10, 20, 30, 40]
: tabcolumn = make_array (n_elements (column1), value = tab)
: status = dc_write_fixed ('testc.dat', /column, $
: column1, tabcolumn, column2, format='%d%s%d')
: status = dc_write_fixed ('testf.dat', /column, $
: column1, tabcolumn, column2, format='(i1, a, i2)')
: (Unfortunately, PVWave will not recognize '%d\t%d' in the C-like way,
: but will just write out the literal character pair or a backslash
: followed by a lower-case t.)
: Hope this helps
: Stephen Ritcey.
That was the problem. I had been trying to put a \t in
the format statement. This *seemed* like it should work.
Oh, well.
I also got it to work with dc_write_free by setting delim=tab
where tab=string(9B). This way the formatting is taken care
of already.
Thanks!
Kyle J.
|
|
|
Re: Tab-Delimited Files [message #9035 is a reply to message #9034] |
Thu, 22 May 1997 00:00  |
Jim O'connor
Messages: 7 Registered: March 1996
|
Junior Member |
|
|
rkj@dukebar.crml.uab.edu (R. Kyle Justice) writes:
> Is there a way to create tab-delimted files in
> PV-Wave?
>
> I have columns of data and I would like to
> separate them by tabs instead of spaces. I
> can't seem to get it to work with Fortran
> or C format codes in DC_WRITE_FIXED.
>
> Kyle J.
>
>
This is kludgy, but it works.
Wave> tabchar = '\x09'
Wave> z = [[1,4,7],[2,5,8],[3,6,9]]
Wave> status = dc_write_free('/tmp/junk.txt', z, /Col, Delim = tabchar)
But /tmp/junk.txt has spaces, as well as the tab characters you wanted.
So pull a Deus Ex Machina out of a hat, and strip off the spaces
using Perl:
% perl -pe 's/ //g' /tmp/junk.txt >/tmp/junk.txt.new
And there's your rabbit.
--
Jim
|
|
|
Re: Tab-Delimited Files [message #9036 is a reply to message #9034] |
Thu, 22 May 1997 00:00  |
sritcey
Messages: 5 Registered: March 1997
|
Junior Member |
|
|
R. Kyle Justice (rkj@dukebar.crml.uab.edu) wrote:
: Is there a way to create tab-delimted files in
: PV-Wave?
: I have columns of data and I would like to
: separate them by tabs instead of spaces. I
: can't seem to get it to work with Fortran
: or C format codes in DC_WRITE_FIXED.
The following works for me...
tab = string (9B)
column1 = [ 1, 2, 3, 4]
column2 = [10, 20, 30, 40]
tabcolumn = make_array (n_elements (column1), value = tab)
status = dc_write_fixed ('testc.dat', /column, $
column1, tabcolumn, column2, format='%d%s%d')
status = dc_write_fixed ('testf.dat', /column, $
column1, tabcolumn, column2, format='(i1, a, i2)')
(Unfortunately, PVWave will not recognize '%d\t%d' in the C-like way,
but will just write out the literal character pair or a backslash
followed by a lower-case t.)
Hope this helps
Stephen Ritcey.
|
|
|