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
 import every nth file

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
Adamantan Posted - 06/18/2024 : 04:20:08 AM
Hey,
I have a large data set consisting of 3000 IR spectra in 3000 csv files that I would like to import. However, it would be impractical to import every single spectrum first and then delete the unwanted ones. How can I simply import, say, every 10th file without changing the original dataset?

Best regards,
Michael

Origin Ver. and Service Release: 2022b (64bit) 9.9.5.167
Operating System: Win10
2   L A T E S T    R E P L I E S    (Newest First)
aplotnikov Posted - 06/19/2024 : 04:58:43 AM
Import every n-th file:

int n=10;
string strDataPath$="X:\\AAA\\BBB\\";
findFiles path:=strDataPath$ ext:="csv" addpath:=1;
for(int iFileBeg = 1; iFileBeg < fname.GetNumTokens(CRLF); iFileBeg++) {
	int iFile;
	loop(iFile, 1, n-1) {
		fname.Replace(fname.GetToken(iFileBeg+1, CRLF)$ + "%(CRLF)", "");
	}
}
impASC;


If you have sequentially numbered files, you should combine the file names (including the data path) into the fname$-string in a loop:
int n=10;
int nFiles=20;
int iFile;
string strDataPath$="X:\\AAA\\BBB\\";
string strPrefix$="%(strDataPath$)spec_";
string strSuffix$="_xyz";
fname$="";
loop(iFile, 0, nFiles-1) {
	fname$ = fname$ + "%(strPrefix$)$(iFile*n+1, #4)%(strSuffix$).csv%(CRLF)";
}
impASC;


Use your own values for n, nFiles, strDataPath$, strPrefix$, strSuffix$ as well as the format of the sequential number. Tune the import options if necessary (see the impASC-X-Function documentation).
YimingChen Posted - 06/18/2024 : 09:01:25 AM
You can select multiple csv files in Windows Explorer, and drag them into Origin workspace to import.

James

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