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
 Origin Forum
 Importing under LabTalk + plotting under LabTalk

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
a_user Posted - 08/14/1998 : 7:43:00 PM
I've just started programming in LabTalk and I'm still stuck with some things. I want to add some extra menus for automatic importing and plotting of data.

I have a series of ASCII files (*.DAT and *.DAR files) containing only Y-values. All these file have ascending names (type: XXXXX### where x is a letter and # a number). I want to program a menu where I give the first filename and the last filename and using LabTalk all files between these are imported into columns of the worksheet.

I would also like to be able to automatically plot these columns using an X column created and added to the spreasheet (I got that to work). It should be like this: The user selects the Y-columns with the mouse and selects the menu. Using a slected template all columns should be plotted on a graph. I have tried some possibiliies but I cannot seem to avoid that a dialog box pops up and asks to select the x and y columns for the plot. Can anybody help me out with these two problems ?

Thanks,

Peter Thoen
Lab. Vaste-Stoffysika en Magnetisme
K.U. Leuven

2   L A T E S T    R E P L I E S    (Newest First)
a_user Posted - 08/14/1998 : 7:47:00 PM
...how to import consecutive filenames into Origin

In my view, the hard part is how to tell Origin which is the following filename.
I did it this way:

def GetNewName { /*Increases extension in %A: from lala.010 to lala.011*/
%K=1%[%A,>"."]; /* %K gets the value 1 followed by the file extension*/
%K=$($(%K)+1); /* The value of %K is increased (e.g.from 1000 to 1001)
%K=%[%K,>"1"]; /* Only characters after the first 1 remain (001) */
%A=%[%A,"."].%K; /* Finally, %A substitutes its extension by %K */
}

GetNum (Number Of Data Files) DataFiles; /*Number of files to be imported */
GetFile -w *.*; /* Open the first file (%A) */
repeat DataFiles{
document -t mytemplate.otw; /* Open template */
open -w %B%A; /* Import data from file %A (%B:path)*/
window -r %H %A; /* Rename worksheet to %A */
PlotData; /* macro for plotting */
GetNewName; /* macro for getting new file name */
win -i; /* iconize current worksheet*/
}

This script asks for the number of files to be imported, and for the name of
the first file (%A). The file is imported into a template and plotted (you can
define your options in macro PlotData).
Then, the following filename is choosen in macro GetNewName: the idea is to
have an index varible starting at 1000. Each time a new file is selected, the
index counter is increased, 1001, 1002, 1003... The filename is constructed
using the last 3 characters, that is, 001, 002, 003 and so. In this case, it
was the extension that was changing from one file to the following.
I hope it helps

Juanma

a_user Posted - 08/14/1998 : 7:45:00 PM
.... Importing multiple files with Labtalk

Hello Peter, hello World
today I had a problem very similar to yours.
So here is the code to get things working:

# STARTOPTIONS
ibegin=0;
iend=40;
%L=blabla;
%B=D:\user\peter\daten\hygel\sorp\ ;#Path
# GET PATH & FILENAME
type -b Now read in first file for determination of path;
wks.col1.name$=fakeX;wks.col1.type=4;
GetFile *.DAT;
type -b The path is ->%B \n the file is ->%A;
%L=%[%A,7];
getnumber (Beginvalue) ibegin (Endvalue) iend (Prefix) %%L (Gnuplot rules);
for (k=ibegin;k<=iend;k+=1){
%M=%B%L;
%O=;
if (k<=9){%O=%O$(0)};
%S=%O$(k);
%M=%M%S.DAT;
worksheet -c %S;
type -b read in number $(k) \n with name %M;
open -W %M;
%H_%S=%H_fakeX;
};
for (l=1;l<=200;l+=1){%H_fakeX[l]=l*20};
worksheet -s 0 0 0 0;
worksheet - p 201;

for your problem you need one more leading zero.(if (k<=99)%O=%O$(0)
There should be a simpler and more elegant way to do leading zeros, but with my limited knowledge of C-Formatting Conventions I didn't succeed. Maybe this is one of the frequent cases that even simple things cannot be done with Origin...
The Skript always imports data in its first column (%H_fakeX)and subsequently copies it to the new ones created.
So much for the import problem.
If you need not manipulating your data you will find the open multiple files option ( open a graph window and you'll see it) more comfortable.
ad plot-problem:
the skript above plots all columns(fakeX as x, the rest is y-columns). If you want to exclude some you can insert a wks.colXX.type=2;for the column nr. XX before the worksheet -s is executed. If you want to plot different columns for each project I would suggest to plot everything and to delete the ones you don't need in the plot associations menu.


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