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
 Origin Forum
 script for copying data from multiple files

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
jqian Posted - 06/20/2016 : 2:49:22 PM
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
1   L A T E S T    R E P L I E S    (Newest First)
yuki_wu Posted - 06/21/2016 : 05:47:41 AM
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

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