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
 All Forums
 Origin Forum for Programming
 LabTalk Forum
 Splitting Data from one Worksheet

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

Screensize:
UserName:
Password:
Anti-Spam Code:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkUpload FileInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
rebbit Posted - 08/13/2014 : 06:16:30 AM
Origin Ver. and Service Release (Select Help-->About Origin): 9.0.0G SR2
Operating System: Windows 7 64bit

Hello everybody.

I have one worksheet which is structured like the following example

newWSname1 - Info - Data - Data - Data
newWSname2 - Info - Data - Data - Data
newWSname2 - Info - Data - Data - Data
newWSname2 - Info - Data - Data - Data
newWSname2 - Info - Data - Data - Data
newWSname1 - Info - Data - Data - Data
newWSname1 - Info - Data - Data - Data


i found a script online which does the split almost perfect to

newWSname1
Info - Data - Data - Data
Info - Data - Data - Data
Info - Data - Data - Data


newWSname2
Info - Data - Data - Data
Info - Data - Data - Data
Info - Data - Data - Data


based on those splitted newWorksheets, i built some graphs.


my Problem now is, if i change the Data in the first worksheet and want to update it to the existing newWorksheets, the script deletes every existing newWSname# and creates new ones. Now the graphs won't work anymore.
I tried to modify the code, so if the newWSname# already exists, only the cells will be deleted and filled again with new data.

I know, that there is a solution, but i don't know how to do it.
May you help me?

in a short way i need a script that does:

1. get every different "newWSname#"
2. if newWSname# worksheet exists, update existing
else create newWSname'

the script i found:

// Data range to perform discrete frequency count
range makeCol = !col(Zugfamilie);

// Worksheet to be extract
range sourceWks = !;

// Clear worksheets
int sheetNum = page.nlayers;
int colNum = wks.ncols-1;
if (sheetNum>1)
{
for (jj=2; jj<=sheetNum; jj++)
{
layer-d 2;
}
}

// Tree variable to hold discfreqs outputs
tree tr;

// Perform discrete frequency count
discfreqs irng:=makeCol rd:=tr;

// String array to get result from tree
StringArray sa;
sa.Append(tr.FreqCount1.Data1);
if(sa.GetSize() != NANUM )
{

// Loop to extract data
for (ii=1; ii<=sa.GetSize(); ii++)
{
string sn$ = sa.GetAt(ii)$;

// Extract condition string
string cond$ = "makeCol$ = " + sn$;

// Create worksheet with different Make name
newsheet name:=sn$ cols:=colNum outname:=on$
active:=0;

// Extract data
wxt test:=cond$ iw:=sourceWks c2:=colNum ow:=on$;
}
}



is there also the possibilty to create graphs automatically?
as you can see, every worksheet looks the same, so the graphs will be identic too.
But to create 100graphs by hand ...


Thank you for support!
6   L A T E S T    R E P L I E S    (Newest First)
rebbit Posted - 08/14/2014 : 1:46:51 PM
Thank you!
That's exactly what I am looking for

Have a good day!
greg Posted - 08/14/2014 : 09:14:16 AM
You should try Themes...

Right-click on a 'good' graph (outside the layer/axes) and choose "Save Format as Theme..."
Give your Theme a name (optional description) and click OK.
Open any project which has graphs that need to be fixed.
Press F7 to open the Theme Organizer.
Select your new theme in the Graph tab.
Change "Apply Theme to" to "Graphs in Project" and click "Apply Now".

That last step can also be executed with script:
themeApply2g theme:="My Theme" option:=project;
rebbit Posted - 08/14/2014 : 03:09:38 AM
With "throw a new template" I mean:
There are several graphs. Each one based on one "newWSname#".
I designed the first one, saved it as template and used that for the remaining graphs.
During the working process I noticed some things that needed to be fixed in every graph, for example let's say the text object with the graph titel should be centered.
Now I fix it in one graph, save it as a template and then?
How do I put another template on an existing graph?

If this does not work or may be too complex, what about the idea to create a new graph after the script split the first worksheet?
What commands do I need?


And anyway, is there something like a dictionary, where I can look up the commands? http://wiki.originlab.com/~originla/ltwiki/index.php?title=Script:Creating_Graphs


EDIT:
I found a way to update them.
I put
//Create Graph
plotxy iy:=(1,7:13) plot:=200 hide:=0 ogl:=[<new template:=usertemplate1 name:=on$>];

to a new column into the "Before formula script" section.

This works well for creating a new graph, but not for an update. For that I need to delete old graphs and create new ones by script.
After creating, the scales need to be fixed again.
Any Ideas how to work with that?
greg Posted - 08/13/2014 : 1:58:31 PM
Maybe the graphs lost one line because of the wxt XF removing one column?
Graphs should just update with any change in data. Easiest 'fix' is to remove that c1:=2 and rerun the script.

I don't know what your plan is with "throw a new template to an already created graph" but here is a possibility:
layer -c; // Count datasets in current layer and add to %Z
page -l column; // Add a new layer based on a template (column.otp)
page.active = 1; // Make the first layer active
layer -d; // Delete it
layer -i %Z; // Add all the datasets from %Z to the new layer
layer -a; // Rescale

If your text object is already centered, you can attach it to PAGE or attach it to LAYER FRAME (Programming Control) and set it to use "Center Multi Line" (Properties) and however the text changes, it will remain centered on the PAGE or LAYER.
rebbit Posted - 08/13/2014 : 1:17:23 PM
Hey greg.
That worked nearly perfect!

In the "NewWSname#" the Data is updated.

Now the graphs lost one line, which is the last column in the sheets.
Any idea how to fix this without clicking on every single graph and add it again?

Is there also a way to throw a new template to an already created graph?

And is there a way to align the Graph-Title always to the center?
greg Posted - 08/13/2014 : 1:00:24 PM
Two small changes:

Replace
layer-d 2;
with
wclear w:=$(jj)! msg:=0;

and add use:=1 to the newsheet XF, like:
newsheet name:=sn$ cols:=colNum outname:=on$ active:=0 use:=1;

You can add a new column to your source worksheet and put the whole script in the "Before Formula Script" and set the Recalculate to Manual.
Then any additional data in your source worksheet will get added once you click Recalculate.
(Auto will not work here because the script would run after adding a new name and would not wait for Info and Data1, Data2, Data3.)

You can improve the script further by modifying the WXT XF to not copy now redundant names:
wxt test:=cond$ iw:=sourceWks c1:=2 c2:=colNum ow:=on$;

The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000