Author |
Topic |
|
neutrondude
Brunei
Posts |
Posted - 04/19/2010 : 10:49:10 AM
|
XP Prof/Origin 7.5
Dear all, I would like to know how I can export all my data worksheet in my project to ASCII files. I have only three out of three columns I would like to export: lets call them A, B, C, D. How can I export A C D??
I have an old export script- but I only succeed to export the "active window" (using the script window). How can I run the script over all datasets and only export the three columns I need ?
/ Setup the WKS.EXPORT object wks.export.c1 = 1; wks.export.c2 = 0; // All columns wks.export.r1 = 1; wks.export.r2 = 0; // All rows wks.export.separator$ = "\t"; // Use TAB separator wks.export.cntrl = 7; // Export Column Names + Data + Column Labels // Loop over al worksheets in the project doc -e W { save -wh %H D:\TEMP\%H.DAT; // -wh uses WKS.EXPORT object }
Thanks a lot in advance!! |
|
Penn
China
644 Posts |
Posted - 04/20/2010 : 03:21:18 AM
|
Hi,
You can loop all worksheets to export the data. For each worksheet, the first thing is to set column A, C and D to be selected, then export the selected data. Please refer to the following script.
wks.export.separator$ = "\t"; // use Tab separator wks.export.cntrl = 15; // export selected data, Column Names + Data + Column Labels // loop all worksheets in the project doc -e W { wks.colSel(1, 1); // select column A wks.colSel(3, 1); wks.colSel(4, 1); save -wh %H D:\TEMP\%H.DAT; };
Penn OriginLab Technical Services |
Edited by - Penn on 04/20/2010 03:36:16 AM |
|
|
neutrondude
Brunei
Posts |
Posted - 04/21/2010 : 04:40:07 AM
|
Dear Penn, thanks a lot but I still cant make it work. I can only get an output if I have a marked worksheet and only this then get exported. Also, it also selects all coloumns then..
How do I run the script and make it understand that certain coloumns of ALL worksheets needs to be exported without marking one by one? Also I would like to avoid to include the coloumn names - i.e. to get pure data files.
quote: Originally posted by Penn
Hi,
You can loop all worksheets to export the data. For each worksheet, the first thing is to set column A, C and D to be selected, then export the selected data. Please refer to the following script.
wks.export.separator$ = "\t"; // use Tab separator wks.export.cntrl = 15; // export selected data, Column Names + Data + Column Labels // loop all worksheets in the project doc -e W { wks.colSel(1, 1); // select column A wks.colSel(3, 1); wks.colSel(4, 1); save -wh %H D:\TEMP\%H.DAT; };
Penn OriginLab Technical Services
|
Edited by - neutrondude on 04/21/2010 04:44:17 AM |
|
|
greg
USA
1378 Posts |
Posted - 04/22/2010 : 2:26:39 PM
|
Your original script included header and ignored selection (cntrl=7). To export selected data you must both select that data and use cntrl=8 (plus any other bits, but you now seem to want none). Penn's wks.selcol(ColumnNum, mode) controls the selecting process for you. In case you have some columns selected in the sheet already, I would only add a 'de-selector' first. Also, to save the tedium of responding to that dialog constantly, this script gets a path then uses that path for all files and use the worksheet name for the file:
// Use this to get a default save path for all files getsave dummy.dat; %A=%[%A,1:%[%A]-9]; // Now loop over all the sheets doc -e W { wo -s; // Remove any existing selection wks.colsel(1,1); // Select column 1 wks.colsel(3,1); // Select column 3 wks.colsel(4,1); // Select column 4 wks.export.cntrl = 8; // Just export selected data - no headers wks.export.separator$ = "\t"; save -wh %H %A%H.DAT; wo -s; // Remove our selections }
Make sure you have the latest 7.5 to avoid issues with certain HP printer drivers. http://www.originlab.com/www/support/resultstech.aspx?language=english&ID=1080 |
Edited by - greg on 04/22/2010 4:04:08 PM |
|
|
|
Topic |
|
|
|