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
 Problem with variable lines of header

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
rmtruji Posted - 01/28/2005 : 5:07:51 PM
Origin Version (Select Help-->About Origin): OriginPro 7.5 SR5
Operating System: Windows XP

I've written a routine using Labtalk to import numerous ASCII files. These files have header lines ranging from 30 to 50 lines. My routine strips out the header information and places it in a separate Notes window, then plots the two columns of data.

My routine works fine if the number of header lines in a particular group of ASCII files is consistent because I can set the ASCII options in the worksheet template (Skip main header, number of lines: 30).

The problem occurs when my group of ASCII files each have a different number of header lines, therefore setting ASCII options is not an option.

Is there perhaps a way to avoid using a worksheet template and writing the solution in Labtalk?

Thanks,

Gina
1   L A T E S T    R E P L I E S    (Newest First)
Mike Buess Posted - 01/28/2005 : 5:45:20 PM
Hi Gina,
quote:
The problem occurs when my group of ASCII files each have a different number of header lines, therefore setting ASCII options is not an option.
So the "Auto determine to skip more header lines" option does not work for your files?
quote:
Is there perhaps a way to avoid using a worksheet template and writing the solution in Labtalk?
You can use OriginPro's File Utilities Module (FUM) to read the file a line at a time and programmatically determine where the header stops. (See the File Utilities section of you Origin Pro manual for details.) However, if you are unfamiliar with LabTalk's FUM you might be better off directing your learning efforts at Origin C instead. It offers much more flexibility than any LabTalk solution to this and most other Origin problems.

...The following simple Origin C function works well with ASCII files with variable headers.
void import_ascii(string sFile)
{
ASCIMP ascimp;
if(AscImpReadFileStruct(sFile, &ascimp)==0)
{
Worksheet wks;
wks.Create(); // create wks from default template
// wks.Create("MyTemplate.otw"); // create from custom template
wks.ImportASCII(sFile, ascimp);
}
}
Assuming you currently import with a LabTalk script that looks like this...

win -t D MyTemplate;
open -w %B%A; // %B is path, %A file name

you can try this instead...

import_ascii %B%A;

The header information still appears in the string variable %Z.

Mike Buess
Origin WebRing Member

Edited by - Mike Buess on 01/29/2005 11:52:37 AM

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