T O P I C R E V I E W |
tbarrou |
Posted - 01/23/2013 : 10:22:44 AM Origin Ver. and Service Release (Select Help-->About Origin): 9.0 SR1 Operating System: win7
I imported a lot of data from Matlab (30 MB). It has been imported as double on about 6k columns. However, these values can be coded only on 10 bits...
Is there a handy way to change the data type (from double to short) for all columns of all worksheet of a workbook ? it would dramatically reduce the memory size...
thanks a lot.
|
5 L A T E S T R E P L I E S (Newest First) |
snowli |
Posted - 01/24/2013 : 09:22:41 AM Hello,
With the worksheet you want to change active, run the following in Script window. It will only change data type of your active worksheet.
loop(ii,1,wks.ncols) {wks.col$(ii).format=1; wks.col$(ii).numerictype=3}
As to the GUI way, please select all columns by highlight 1st column and drag to select all columnns. Then right click to choose Properties context menu.
In the dialog that opens, the title should list all columns you selected, e.g. [Book1]Sheet1!(A,B,C,D,E)
When you change options, it will apply to all the columns.
We found there is a bug when click upper-left corner to select whole worksheet and then change Column Properties. You may notice the dialog title shows Book1]Sheet1!(A,A) and it only applis to col A. We have jiraed it to fix in the future.
Thanks, Snow Li OriginLab Corp.
quote: Originally posted by tbarrou
Hi Hideo,
I first tried to select column and use right-click/properties... However this does not change the data type of all selected columns. I tried also by selecting all data with a click in the top-left corner of worksheet, but in the same maner changes in properties pop-up dont apply to the column but the first one. Furthermore, my workbook contain 35 worksheets, so it would be usefull to be able to select all column of all wks of the workbook.
Unless I'm wrong, the doc-e LB command will loop over all workshhet of the project. Is there a way to loop only on worksheet of the active workbook ?
Thanks a lot for your support
|
tbarrou |
Posted - 01/24/2013 : 04:23:08 AM Hi Hideo,
I first tried to select column and use right-click/properties... However this does not change the data type of all selected columns. I tried also by selecting all data with a click in the top-left corner of worksheet, but in the same maner changes in properties pop-up dont apply to the column but the first one. Furthermore, my workbook contain 35 worksheets, so it would be usefull to be able to select all column of all wks of the workbook.
Unless I'm wrong, the doc-e LB command will loop over all workshhet of the project. Is there a way to loop only on worksheet of the active workbook ?
Thanks a lot for your support
|
snowli |
Posted - 01/23/2013 : 1:25:37 PM Should be
doc -e LB { loop(ii,1,wks.ncols) {wks.col$(ii).format=1; wks.col$(ii).numerictype=3} //1:Double(8), 2:Real(4), 3:Short Int(2), 4:Long Int(4), etc. }
BTW, hightlight all columns in worksheet by selecting all column headers. Right click and choose Properties. You can change Format to be Numeric. Data Type to be Short(2).
Thanks, Snow Li OriginLab Corp. |
tbarrou |
Posted - 01/23/2013 : 12:40:27 PM When the initial data format is "text & Numeric" , all values are set to 0... I tried col$(ii).setformat (1,3) but it gives double.
Thanks |
Hideo Fujii |
Posted - 01/23/2013 : 10:47:50 AM Hi tbarrou,
The following 3-line script can change the numeric type of all columns in all sheets in all workbooks (and matrices): doc -e LB {
loop(ii,1,wks.ncols) {wks.col$(ii).numerictype=2}
//1:Double(8), 2:Real(4), 3:Short Int(2), 4:Long Int(4), etc.
}
Hope this helps.
--Hideo Fujii OriginLab |
|
|