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
 Export XY columns to each ASCII file
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

RobDU

3 Posts

Posted - 02/04/2018 :  12:35:53 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Ver. and Service Release (Select Help-->About Origin): OriginPro2016 (64-bit) Sr2 b9.3.2.303
Operating System: Windows Server 2012 R2 Standard

Hi,

I would like to export data from a worksheet. This worksheet has more than 150 columns, 1st is X the following are Y. I want to export each Y column together with the X column each to a separate *.dat file. i.e.
Filename1 X Y1
Filename2 X Y2

How can I do this? Is there a possibility?

Thank you in advance.

Rob

yuki_wu

896 Posts

Posted - 02/05/2018 :  01:07:23 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Rob,

I think you can try LabTalk script. For example, I stored the data in [Book1]Sheet1!, then I can:
1. Select Window: Script Window form menu
2. Copy and paste the script into Script Window
//Activate the workbook that has 150 columns
win -a Book1;
//Activate the worksheet that has 150 columns
page.active = 1;
//Split worksheet
wsplit mode:=col col:=1;
//Loop over every worksheet
doc -e LW{
	//Copy column X to the active worksheet
	colcopy irng:=[%H]1!Col(1) orng:=!Col(2);
	//Swap column 1 and column 2
	colswap (1,2);
	//Export worksheet to the specified path and name it with the name of the active worksheet
	expASC path:="C:\Users\yuki\Documents\OriginLab\User Files\" + page.active$ + ".dat";
}

4. Select the script to highlight it
5. Click Enter key to run the script

Note that you should rewrite the path to specify where the dat file should be exported.

Regards,
Yuki
OriginLab

Edited by - yuki_wu on 02/05/2018 01:10:46 AM
Go to Top of Page

RobDU

3 Posts

Posted - 02/05/2018 :  4:11:37 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hello Yuki,

thank you for your fast help. So I tried it, but I am getting if the column number is higher than 200 an Attention! window with the following syntax: Unable to add any more layers/sheets to this graph/book. while splitting the columns. Is there maybe another solution without opening sheets?

Is it possible to change the file names in the export function to the Y-column long name? It is needed cause this long name is the time information of my experiment.

Thank you.

best regards

Rob

Edited by - RobDU on 02/05/2018 6:18:27 PM
Go to Top of Page

yuki_wu

896 Posts

Posted - 02/05/2018 :  9:16:48 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Rob,

The number of columns is restricted by the maximum number of sheets in a workbook. In general, the maximum number of sheets in a workbook is 255. If the number of columns is larger than the limitation number, you can split the original worksheet at first, for example:
X, Y1, Y2… Y250
X, Y1, Y2… Y125 and X, Y125, Y126… Y250

To export the file with the long name of Y column:
expASC path:="C:\Users\yuki\Documents\OriginLab\User Files\" + col(B)[L]$+ ".dat";


Regards,
Yuki
OriginLab
Go to Top of Page

snowli

USA
1386 Posts

Posted - 02/06/2018 :  11:13:57 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Rob,

In Origin 2018, we have increased the maximum number of sheets per workook to 1024.


Also try if the following code works for you.
//Don't highlight any column in workbook;
wks.colsel(1,1); //select 1st column;
for (ii=2;ii<=wks.ncols;ii++) //start loop for 2nd column to last column)
{
wks.colsel(ii,1); //select iith column
expASC path:="D:\temp\waterfall$(ii-1).dat" select:=1; //export selected columns
wks.colsel(ii,0); //unselect iith column
}

Thanks, Snow
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