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 for Programming
 LabTalk Forum
 Append Part of Filename into Column Parameter
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

Albaraa

Netherlands
1 Posts

Posted - 03/08/2019 :  10:28:13 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
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

yuki_wu

896 Posts

Posted - 03/11/2019 :  03:04:04 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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
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