Author |
Topic |
|
joss31
France
33 Posts |
Posted - 04/16/2014 : 03:53:45 AM
|
Hi everybody,
I started to use Labtalk on Origin 6.1 a week ago. And I need some help. Thanks to other topic and information on internet I can import multiple ASCII, I can post them in different workbook.
But now I need to take information in the header of the ASCII; for example, I need to save the trigger time in a variable.
My ASCII look like that:
Starttime 08.01.2014 14:35:36 Triggertime 14:35:36.000000000000000 TriggerSample 0 Samplerate 100 Hz Blocklength 47614
Channel echantillon Time Signal s V
0.00000000e00 -16.7500e-03
words in purple is plot in the workbook number in green is the number that i need
My code looks like that :
type -a; //open the Script window getfile -m *.*; // prompt for multiple files worksheet -c allstrtt; //add a Ycolumn & named it allstrtt like "allstarttime" numpts=100000; for (ii = 1; ii <= count; ii ++) { getfile -g ii; // get the iith file into %A open -w %A; // This IMPORTS that file hfile=file.open(%A);// This OPENS the file for processing type -a %A; if (ii< count) { worksheet -d lastpik; //Duplicate the active workbook into a new workbook named lastpik }; if(ii<(count+(count-1))) { worksheet -p 2 template; }; };
Yesterday, I have found something, but I have no idea of how this function can help me & how can I use it, it's this function:
Triggertme = file.read(12,[hfile]); file.cread(A,10); file.nbytes=2; file.signed=1; file.aread(%H_A,1,numpts,0); type -a; Triggertme= ;
So, if somebody can help me, it could be great but dont forget i use an hold version of origin (6.1) .
Thank you for you're attention.
|
Edited by - joss31 on 05/07/2014 04:17:50 AM |
|
greg
USA
1378 Posts |
Posted - 04/16/2014 : 10:36:23 AM
|
Immediately after each import, the %Z string register will hold the header text: Starttime 08.01.2014 14:35:36 Triggertime 14:35:36.000000000000000 TriggerSample 0 Samplerate 100 Hz
// Using substitution notation, get the second line of that text: %A = %[%Z,@2]; // Then you can get the part after the space: %B = %[%A,>' ']; // This is the triggertime value as a string
// If you need each of the time elements as numeric ttHours = %[%B,1:2]; // characters 1 and 2 ttMinutes = %[%B,4:5]; // characters 4 and 5 ttSeconds = %[%B,7:%[%B]]; // characters 7 to the length of %B Triggettime = ttHours /24 + ttMinutes / 1440 + ttSeconds / 86400;
|
|
|
joss31
France
33 Posts |
Posted - 04/17/2014 : 05:06:25 AM
|
Thank you very much Greg. %A = %[%Z,@2]; %B = %[%A,>' ']; It works good on ORIGIN 6.1! It's perfect!
But I don't understand, I put your command:
%A = %[%Z,@2];
// If you need each of the time elements as numeric ttHours = %[%B,1:2]; // characters 1 and 2 ttMinutes = %[%B,4:5]; // characters 4 and 5 ttSeconds = %[%B,7:%[%B]]; // characters 7 to the length of %B Triggettime = ttHours /24 + ttMinutes / 1440 + ttSeconds / 86400;
but when I want to see for example:
plot -a; ttHours;
It put in the script windows ttHours=--
So can you tell me if I do a mistake.
And I've got very important question
Is it possible to put this value in the column "allstrtt"? How?
So, if somebody can help me, it could be great but dont forget i use an hold version of origin (6.1) .
Thank you for you're attention.
|
Edited by - joss31 on 04/17/2014 05:12:10 AM |
|
|
greg
USA
1378 Posts |
Posted - 04/17/2014 : 10:48:20 AM
|
Neither plot -a; nor ttHours; are valid commands.
If ttHours is a missing value as your post suggests, then you need to start looking for the problem. After an import, type %Z= into the script window to see what it contains. If the second line is not something like: Triggertime 14:35:36.000000000000000 then you need to modify %A = %[%Z,@2]; to point to the line with triggertime. e.g. %A = %[%Z,@3]; // It's actually the third line |
|
|
joss31
France
33 Posts |
Posted - 04/18/2014 : 03:23:49 AM
|
ok I have found my problem it was that between my string Triggertime and its value 14:35:36.000000000000000 there's not a space but a Tab Key and then everythings works good Thanks for that.
And now, you know Is it possible to put the Triggertime value in my column allstrtt? |
Edited by - joss31 on 04/18/2014 03:25:12 AM |
|
|
joss31
France
33 Posts |
Posted - 04/18/2014 : 07:43:14 AM
|
No, it's good I put my value with that operation :
col(3)=%(%H,1)+TTIME2;
So, thank you for you're help on this topic Greg. |
|
|
MikeK
6 Posts |
Posted - 05/05/2014 : 08:17:37 AM
|
Hi all,
I have the same problem, but my ASCII file looks quite different:
===================================
===================================
EPR-Scriptprogram (Version: 1.00)
===================================
===================================
------------------------------------------------------------------------------
Date: 03.05.2014 Time: 14:07
------------------------------------------------------------------------------
Sample Name: Mn12
Note: single crystal Mn12Ac, 1.5mg
Measurement Notes:
Magnetic Field: 0.000 T
Field Modulation: 60.14 mA
Temperature: 30 K
Frequency From: 250.00 GHz
Frequency To: 380.00 GHz
Frequency Sweep: 4000.00 GHz/min
======== Measured Values =========
Lock In Identification: Stanford_Research_Systems,SR830,s/n42738,ver1.07
Sensitivity: 50.0e-3
Dynamic Reserve Mode: Normal
Time Constant: 300 ms
Low Pass Filter Slope: 24 dB/oct
Phase: -45.21
Reference Frequency: 1000.0000 kHz
==================================
------------------------------------------------------------------------------
Time/s Frequency/GHz X/arb.U. Y/arb.U. Temperature/K He-Level/% N2-Level/% Modulation Current/mA Zero bias detector/V
2.620000E-1 2.500000E+2 0.000000E+0 0.000000E+0 3.000590E+1 9.548780E+1 7.620680E+1 0.000000E+0 0.000000E+0
4.771000E+0
And the data continue. I would like the extract the bold value of magnetic field. The solution in this thread doesn't work, because when i look at %Z after the import, it holds onlz the column header, not the entire file. An suggestions? Thank you |
|
|
greg
USA
1378 Posts |
Posted - 05/06/2014 : 10:32:24 AM
|
Any version of Origin since 7.5 has the Import Wizard which includes automatic scanning for variables - in this case variables defined by the colon character. http://www.originlab.com/doc/Origin-Help/ImpWiz-ASC-ExtractVarDeliPage After the import, you can access the string containing your magnetic field value with: %A = page.info.user.variables.magneticfield$; val = %[%A," "]; or str$ = page.info.user.variables.magneticfield$; val = %(str.GetToken(1)$);
|
|
|
MikeK
6 Posts |
Posted - 05/07/2014 : 05:20:57 AM
|
Thank you for the reply greg. However, I am quite new to origin scripts, so I have to ask further - your solution uses the import wizard, but if I use the wizard, wouldn't it mean that while importing, I would have to go through the whole wizard for every file? Because I have to import around 60 files....Or is it possible to run the scan for variables inside the file without the wizard? I couldn't find it in the reference. Sorry if I ask trivial questions. Thanks. |
Edited by - MikeK on 05/07/2014 05:21:24 AM |
|
|
greg
USA
1378 Posts |
Posted - 05/08/2014 : 10:43:12 AM
|
Only the Import Wizard has the scan for variables feature. On the last page of the Wizard you can save a filter which can then be used with the impfile function:
dlgfile gr:=*.* mu:=1; loop(ii,1,fname.GetNumTokens(CRLF)) { file$ = fname.GetToken(ii,CRLF)$; impfile fname:=file$ filter:="Three Columns" location:=user; if(ii<fname.GetNumTokens(CRLF)) newbook; }
Above uses a filter named "Three Columns" I saved from the Wizard. |
|
|
MikeK
6 Posts |
Posted - 05/14/2014 : 04:36:29 AM
|
Thank you very much Greg, works like a charm. |
|
|
|
Topic |
|
|
|