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
 script for copying data from multiple files
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

jqian

USA
Posts

Posted - 06/20/2016 :  2:49:22 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
I have to do a lot of data process.

At first I need to import multiple files with same format. The file names are test1, test2 and so on. I would like to copy the #4 column from each of the files and then paste them to a new worksheet.
The next step is delete the first 5 rows from the new worksheet.

Could you help me for a script?

Thanks a lot

yuki_wu

896 Posts

Posted - 06/21/2016 :  05:47:41 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

I think the scripts below can help you in this case:

Import multiple files:

//please make sure the exact path of your files
string fns, path$ = system.path.program$ + "\samples\curve fitting\"; 
//you can change the extension of file to txt, csv and so on
findfiles fname:=fns$  ext:="test*.dat"; 
impasc fname:=fns$
options.ImpMode:=4 //start new sheets 

Copy columns:

//loop over all the worksheets and copy column#4 of each worksheet to a new worksheet named summary
doc -e LB {colcopy irng:=Col(4) orng:=summary!Col(ii)}; 
wks.nCols = wks.nCols-1; //delete the last column 

Delete rows:

wks.deleteRows(1,5);


If you want to know more details of the scripts, you can select Help: Programming: Labtalk from Origin menu.

Hope the information helps.


Regards
Yuki
Originlab Technical Service Team
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