comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: exporting table data to a CSV file
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: exporting table data to a CSV file [message #36445 is a reply to message #36439] Thu, 18 September 2003 03:19 Go to previous messageGo to previous message
Isa Usman is currently offline  Isa Usman
Messages: 13
Registered: October 2001
Junior Member
"Tim Williams" <timothy.williams@nvl.army.mil> wrote in message
news:faf44c99.0309170518.45b76bff@posting.google.com...
> Hi.
>
> I want to output the contents of a table to a CSV file for import to
> Excel, or perhaps something else. I don't know in advance the data
> type of the cells, so I can't use the FORMAT= keyword. I've coded up
> something, but I know FOR loops are "bad" and was wondering if there
> is a better way.
>
> Here's what I have (coding from memory here)
>
> widget_control, table, get_value=values
> labels=tag_names(values)
>
> ;write header
> printf, lun, strjoin(labels, ', ')
> outarr=strarr(n_tags(values))
> ;write out each row
> for i=0, n_elements(values)-1 do begin
> for j=0, n_tags(values)-1 do outarr[j]=values[i].(j)
> printf, lun, strjoin(outarr, ', ')
> endfor
>
>
> Is there a better way to do this?
>
> I also saw David Fannings code about writing CSV files, and learned
> about the WIDTH keyword to OPEN. What's a good way to get the max
> width of the table so my output won't get truncated?
>
> Thanks.

There is a routine called write_csv_data that does what you are looking for.
Just do a google search and you should find it.

Isa
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: What does an optimal scientific programming language/environmentneed?
Next Topic: Re: lens distortion

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Fri Oct 10 22:41:50 PDT 2025

Total time taken to generate the page: 1.24115 seconds