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
 Origin Forum
 Partial Import using keywords
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

Kujo

2 Posts

Posted - 06/21/2019 :  05:18:58 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Hi!
I'm trying to set up an import filter that allows me to do a partial import of a certain part of my files. Unfortunately this part isn't always between the same number of lines but the desired data is separated by certain keywords.
So in particular the data starts after the keyword "elustart" and ends after "elustop".

So it looks like this:


useless useless useless
useless useless useless

ELUSTART

col1 col2 col3
col1 col2 col3
col1 col2 col3
col1 col2 col3

ELUSTOP

useless useless useless
useless useless useless




Is there any way I can automate the import of this data so I don't have to manually copy it or manually check the lines it is in?
I've been looking quite a bit for a way to do this, including labtalk scripts (the way I would probably prefer) but to no avail so far.

Hope you have ideas on this.

Thanks!

YimingChen

1618 Posts

Posted - 06/21/2019 :  2:22:26 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

In Import Wizard tool, under Header Lines page, uncheck the box Auto Determine Header Lines, make sure Number of Main header lines and subheader lines are both set to 0. Go all the way to last page, use the following script in Script After Each File Imported.

James


range r1 = col(A);
n = r1.getSize();
ns = lookup("ELUSTART", r1, data(1,n));
wks.deleteRows(1,ns+1);

n = r1.getSize();
ns = lookup("ELUSTOP", r1, data(1,n));
wks.deleteRows(ns-1,n-ns+2);



Edited by - YimingChen on 06/21/2019 2:22:51 PM
Go to Top of Page

YimingChen

1618 Posts

Posted - 06/21/2019 :  2:41:19 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

Would you mind sharing your real data with us? We would like to improve our CSV data connector on partial import, maybe we can import partial rows with some syntax like ELUSTART:ELUSTOP. If you would like to share, please send your data to <tech@originlab.com>. Thank you.

James

Edited by - YimingChen on 06/21/2019 2:42:11 PM
Go to Top of Page

Kujo

2 Posts

Posted - 06/24/2019 :  04:58:06 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thank you for your help, unfortunately when using the given script I receive an error "scn.GetToken(1, "_")$" and the imported data is not getting cropped.

Also, I sent you the original data as requested.

#Edit: OK the error seems to come from a part of another script I'm using with my import filter. With a fresh filter using only your script (slightly modified) it works, thank you.

range r1 = col(A);
n = r1.getSize();
ns = lookup("ELUstart :", r1, data(1,n));
wks.deleteRows(1,ns+1);

n = r1.getSize();
ns = lookup("ELUstop :", r1, data(1,n));
wks.deleteRows(ns-1,n);

Edited by - Kujo on 06/24/2019 05:10:25 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