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
 Coding error using Import Wizard

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
onsight8c Posted - 01/08/2015 : 08:31:40 AM
Origin Ver. and Service Release: 9.0.0G SR2 b87
Operating System: Win7x64

Hey everybody,

it has been some years since I last asked for some help here at the originlab forum. But today I'm stuck in a -most probably- very simple coding problem, again.

Basically, I want to import the four data files named "Messwerte----CHAx CAL" via the import wizard.


Then I have to extract column 3 from those files into a new workbook ("Zusammenfassung" or results) and label the copied data according to the number of the data file ("Messdose 1" to "Messdose 4" in the comment line). The time stamp in column A(X) is copied only once from any file. When I do that manually, it looks like the following:


But as I have some hundreds of data files, I need a script that produces the results workbook automatically. I used to implement some Labtalk script at the end of the import wizard where you can set advanced filter options. There I put the following code to be run after each single imported file:


%R=%H; // Store workbook name.
%T="Zusammenfassung Zugkraefte"; // Define window name for tensile force results.
itest=exist(%T);
if (itest==2)
{
win -a %T; // Activate tensile force Results Window.
wks.addCol(); // next column
nn=wks.nCols;
wks.col$(nn).type=1; // Make data in col(nn) type Y.
}
else {
newbook name:= "Zusammenfassung Zugkraefte"; // Create tensile force results workbook.
nn=wks.nCols;
}
Col($(nn))[L]$="Zugkraft";
Col($(nn))[U]$="kN";
Col($(nn))[C]$="Messdose"$(nn-1);
range rr=[%R]1!Col(3), tt=[%T]1!Col($(nn)); // Assign datasets for copying using range notation. Copy column 3 (tensile force) from source file CALx to Col(nn) in %T
colcopy irng:=rr orng:=tt; // Copy Y data.


The result is this with several errors:


The errors are:

  • Longname, Unit and Comment are written in every CHAx-file except in CHA1 (should only be written in "Zusammenfassung" workbook)

  • in all CHAx workbooks "Messdose 1" is written as comment: at least it should be number 1 to 4 - but still incorrect as mentioned above

  • only y-values of CHA4 have been written to the generated "Zusammenfassung" workbook and labeled incorrectly with "Messdose 1" instead of "Messdose 4"



Does anyone of you has an idea where the error is in my code? I don't get it after several hours of bug-chasing

Here are the data files:
http://www.originlab.com/ftp/forum_and_kbase/Images/data-files.zip


The import filter file .oif
http://www.originlab.com/ftp/forum_and_kbase/Images/Spider-Rohdaten-Import.zip

Thank you all in advance for your support!
Boris
3   L A T E S T    R E P L I E S    (Newest First)
lkb0221 Posted - 01/08/2015 : 11:03:17 AM
The key is using Start New Columns as import mode and do partial import in Import Wizard.

Here is the script that runs in the end:
// Start
// Set long name, units and format for column 1
col(1)[L]$="Uhrzeit";
col(1)[U]$="hh:mm";
wks.col1.SetFormat(3,3);
wks.col1.type = 4;

for (int col = wks.ncols; col >= 2; col = col - 2) {
// Set long name and units for rest of the columns
col($(col))[L]$ = "Zugkraft";
col($(col))[U]$ = "kN";
col($(col))[C]$ = "Messdose $(col / 2)";
// Delete duplicated time columns
if (col != 2) {
range rr = $(col - 1);
delete rr;
}
}
// End
onsight8c Posted - 01/08/2015 : 10:15:31 AM
Hey Zheng,

I just wrote you an email.

cheers,
Boris
lkb0221 Posted - 01/08/2015 : 10:03:42 AM
Hi, Boris

Can you send an email to <tech@originlab.com> ? So that I can send you back the filter I made.

Zheng
OriginLab

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