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 for Programming
 LabTalk Forum
 Append Part of Filename into Column Parameter

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
Albaraa Posted - 03/08/2019 : 10:28:13 AM
Hello,

I import my data files into columns within a sheet. I'm looking for a way to add the last 5 characters in each filename as a new parameter for each column.

For example, I run an experiment and my data are recorded as a hundred consecutive csv files. The time that each measurement is made is not included inside the file but is part of the filename, e.g.: "2-091_Polym_2D18_150C_13-41.csv". I import all 100 files into 100 columns in a single sheet in Origin with the full filename in the comments (append filename to comments option while importing). I would like to add another parameter cell for "time" where the last "13-41" part is added. The full filename is variable but the time is always the last 5 characters before the extension.

I'm completely new to Origin and I appreciate your help!

Thanks,
Albaraa

__

Origin Ver. and Service Release (Select Help-->About Origin): OriginPro 2019 (64-bit)
9.6.0.172

Operating System: Windows 10
1   L A T E S T    R E P L I E S    (Newest First)
yuki_wu Posted - 03/11/2019 : 03:04:04 AM
Hi,

Please try the script below:

string strPath$ = "C:\MyData";
findFiles path:=strPath$ fname:=results$ ext:="csv";
int nn = results.GetNumTokens(CRLF);
newbook;
wks.UserParam1 = 1;
wks.UserParam1$ = "Time";
loop(ii,1,nn)
{
	fname$ = results.GetToken(ii, CRLF)$;
	strTime$ = left(right(fname$, 9)$, 5)$;
	impCSV options.FirstMode:=1 options.scripts.ScriptAfterEachImport:="wcol(ii)[D1]$ = strTime$;";
}


Regards,
Yuki

OriginLab

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