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
Username:
Password:
Save Password
Forgot your Password? | Admin Options

 All Forums
 Origin Forum for Programming
 LabTalk Forum
 Problem with variable lines of header
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

rmtruji

USA
10 Posts

Posted - 01/28/2005 :  5:07:51 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
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

Mike Buess

USA
3037 Posts

Posted - 01/28/2005 :  5:45:20 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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
Go to Top of Page
  Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000