write widget_table out to file?

This is a discussion on write widget_table out to file? within the Idl-pvwave forums in Programming Languages category; 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...

Go Back   Application Development Forum > Programming Languages > Idl-pvwave

Object Mix

Register FAQ Calendar Search Today's Posts Mark Forums Read
  #1  
Old 08-29-2008, 12:54 PM
Mike
Guest
 
Default write widget_table out to file?

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
Reply With Quote
  #2  
Old 08-29-2008, 01:57 PM
Jean H
Guest
 
Default Re: write widget_table out to file?

Mike 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



WIDGET_CONTROL, table_ID, GET_VALUE=tblValue

openW, lun, filename, /get_lun
printf, lun, tblValue
close,lun
free_lun, lun

Jean
Reply With Quote
  #3  
Old 08-29-2008, 02:01 PM
Bennett
Guest
 
Default Re: write widget_table out to file?

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
Reply With Quote
  #4  
Old 08-29-2008, 02:03 PM
Bennett
Guest
 
Default Re: write widget_table out to file?

On Aug 29, 2:01*pm, Bennett <juggernau...@gmail.com> wrote:
> 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


Hope that helps...at least get you on the right path. It's something
I've used in the path to write out data in a pointer or in a 2D array.
Reply With Quote
  #5  
Old 08-29-2008, 02:05 PM
Bennett
Guest
 
Default Re: write widget_table out to file?

On Aug 29, 2:01*pm, Bennett <juggernau...@gmail.com> wrote:
> 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


The table from the widget has data in a 2D array in my experience
which is what you'd want to put in as the input "array" to the
write_csv function
Reply With Quote
  #6  
Old 08-29-2008, 02:37 PM
Bennett
Guest
 
Default Re: write widget_table out to file?

On Aug 29, 1:57*pm, Jean H <jghas...@DELTHIS.ucalgary.ANDTHIS.ca>
wrote:
> Mike 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

>
> WIDGET_CONTROL, table_ID, GET_VALUE=tblValue
>
> openW, lun, filename, /get_lun
> printf, lun, tblValue
> close,lun
> free_lun, lun
>
> Jean


Well if you want to take the easy way out....
Reply With Quote
Reply


Thread Tools
Display Modes


All times are GMT -5. The time now is 03:44 PM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
vB Ad Management by =RedTyger=

In an effort to better serve ads to our visitors, cookies are used on objectmix.com. For more information, check out our Privacy Policy.