The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
Username:
Password:
Save Password
Forgot your Password? | Admin Options

 All Forums
 Origin Forum
 Origin Forum
 Change data type on a whole workbook
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

tbarrou

France
36 Posts

Posted - 01/23/2013 :  10:22:44 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
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.

Hideo Fujii

USA
1582 Posts

Posted - 01/23/2013 :  10:47:50 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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

Edited by - Hideo Fujii on 01/23/2013 10:59:35 AM
Go to Top of Page

tbarrou

France
36 Posts

Posted - 01/23/2013 :  12:40:27 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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
Go to Top of Page

snowli

USA
1391 Posts

Posted - 01/23/2013 :  1:25:37 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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.
Go to Top of Page

tbarrou

France
36 Posts

Posted - 01/24/2013 :  04:23:08 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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
Go to Top of Page

snowli

USA
1391 Posts

Posted - 01/24/2013 :  09:22:41 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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


Go to Top of Page
  Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000