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

Home » Public Forums » archive » Re: write widget_table out to 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: write widget_table out to file? [message #62256 is a reply to message #62253] Fri, 29 August 2008 11:01 Go to previous message
Juggernaut is currently offline  Juggernaut
Messages: 83
Registered: June 2008
Member
On Aug 29, 12:54 pm, Mike <Michael.Mill...@gmail.com> wrote:
> I'd like to write the contents of a widget_table to a file.  Seems
> like something someone else may have already implemented.  Do any of
> you have something that your willing to share?
>
> Mike

PRO write_csv, array, columnHeaders, $
FILENAME=filename, $
WIDTH=width

ON_ERROR, 1
IF n_elements(array) EQ 0 THEN $
MESSAGE, 'No Array Passed.', /INFORMATIONAL
type = size(array, /type)
IF type EQ 10 THEN BEGIN
IF size(array, /n_dimensions) GT 1 THEN $
MESSAGE, 'Pointer can only be 1D.', /INFORMATIONAL
max_size=intarr(n_elements(array))
FOR i = 0, n_elements(array)-1 DO max_size[i]=(size(*array[i))[1]
sData = strarr(n_elements(array), max(max_size))
FOR i = 0, max(max_size)-1 DO BEGIN
FOR j = 0, n_elements(array)-1 DO BEGIN
IF i GT max_size[j]-1 THEN sData[j,i] = '' ELSE $
sData[j,i]=(*array[j])[i]
ENDFOR
ENDFOR
ENDIF

ndims = size(array, /n_dimensions)
sz = size(array)
IF n_elements(columnHeaders) NE 0 THEN BEGIN
length = n_elements(columnHeaders)
IF length NE sz[ndims] THEN $
MESSAGE, 'Column Header Vector Incorrect Size.', /INFORMATIONAL
ENDIF

IF n_elements(filename) EQ 0 THEN $
filename=dialog_pickfile(/WRITE, file='yourdata.csv')
IF filename EQ '' THEN RETURN
IF n_elements(width) EQ 0 THEN width=1600
IF type EQ 10 THEN xsize=n_elements(array) ELSE xsize=sz[ndims-1]

OPENW, lun, filename, /get_lun, width=width
IF n_elements(columnHeaders) NE 0 THEN BEGIN
sColumns = strtrim(columnHeaders,2)
sColumns[0:xsize-2] = sColumns[0:xsize-2] + ','
PRINTF, lun, sColumns
ENDIF

IF type NE 10 THEN sData = strtrim(array,2)

sData[0:xsize-2,*] = sData[0:xsize-2,*] + ','
PRINTF, lun, sData
CLOSE, lun
FREE_LUN, lun
END
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: write widget_table out to file?
Next Topic: ONLINE RESOURCE FOR HELP DESK SOFTWARE

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

Current Time: Sat Oct 11 17:29:23 PDT 2025

Total time taken to generate the page: 1.27759 seconds