Author |
Topic  |
|
tib
Switzerland
105 Posts |
Posted - 10/21/2003 : 06:10:32 AM
|
Hi all, there have been already quite some questions about Importing ASCII data. But I haven't yet found an answer to the following one:
I have a text file which has an unknown number of header lines. The seperators of the data is an unknown number of spaces. Unfortunately, the header lines start with " #" (space #).
###################### (1) # this is a comment (2) # more comment (3) 10.0 12.1 45.9 12.3 34.5 45.6 # this is again a comment (4) 0.0897 0.317 0.1162 0.2994 0.1486 0.2911 # a comment at the end of line (5) Isn't there a way to tell Origin that anything in a line after certain charater(s) (in this case " #") should be ignored? Would this also work if these lines are no header lines but between data (see (4)). Or even in the same line at the end (5)? Any ideas? Thanks Tilman.
|
|
cpyang
USA
1406 Posts |
Posted - 10/21/2003 : 5:07:25 PM
|
I am not aware of a solution to this. It can be easily added to Origin though, I have added a tracker 5404 about this feature.
CP Originlab
|
 |
|
tib
Switzerland
105 Posts |
Posted - 10/23/2003 : 2:49:56 PM
|
Hi CP, thanks for this info. So, I will have to wait until this will be realized ;-). But maybe you can help me with the following:
I have text data files with comment lines which start with "#". The number of header lines is unknown and variable. There is ONLY ONE row of data. The seperator is TAB. The number of columns is also unknown and variable. The second last comment line contains text which should become the column names. The last comment line contains text which should become the column labels (e.g. units).
#################################### # Data ... # # parameter input file # # postprocessing results... # # column format: # Alq3 STAD R Lum peakX peakY CIEx CIEy # n.A. n.A. W/srm2 cd/m2 nm a.u. n.A. n.A. 1.00e+001 1.00e+001 4.430e+000 3.042e+000 5.080e+002 7.534e-002 2.517e-001 6.521e-001
How do I automatically create such a worksheet by importing the data file? This Worksheet will then serve as template for other data. I couldn't manage it so far with the current ASCII Import Options. Is this possible? What would be the ASCIMPORT settings? Thanks for your help, Tilman.
|
 |
|
cpyang
USA
1406 Posts |
Posted - 10/23/2003 : 4:39:37 PM
|
I don't see a simple solution except in Origin7.5, which has import wizard to specify header lines and to specify which line is to be used for column name and labels.
CP
|
 |
|
tib
Switzerland
105 Posts |
Posted - 10/23/2003 : 6:15:24 PM
|
Hi CP, since I need this function I wrote something. It depends what you call simple...
It seems that the following script does the job... Maybe it will also help others. No guarantee that it works in every case. Tilman.
First you have to put your text file into the variable %Z. See http://www.originlab.com/forum/topic.asp?TOPIC_ID=1935
[ImportSkipComments] %Z=... ; // import file into %Z; SecondLast=0; M%=""; Last=0; %N=""; win -t data Origin; // create wks from scratch; loop (i,1,%[%Z]) { // %[%Z] upper limit of loop; %A=%[%Z,@$(i)]; // extract line; if (%[%A]==0) {break}; // stop loop when last line reached; if (%[%A,1:1]=="#") { // check beginning of line; SecondLast=Last; // remember second last line; %M=%N; Last=i; // remember last line; %N=%A; } else {run.section(,CreateColumns)}; }; run.section(,RenameColumns);
[CreateColumns] loop(ii,1,%[%A]) { // %[%A] upper limit of loop; if (%[%A,#$(ii)]==0/0) {break}; // stop when no more tokens; else { if (%H!wks.nCols<ii) {%H!wks.addCol()}; // add column if necessary; }; };
[RenameColumns] loop(iii,2,ii) { // start from 2nd token; %H!wks.col$(iii-1).name$=%[%M,#$(iii)]; %H!wks.col$(iii-1).label$=%[%N,#$(iii)]; }; wks.labels(); // show labels;
|
 |
|
cpyang
USA
1406 Posts |
Posted - 10/24/2003 : 09:24:36 AM
|
Hi Tilman,
that looks good, and I would say it is not "simple" 
The Origin7.5 import wizard will let you walk through the file once and save the settings (ASCIMP) into an XML file (import filter) so that yo can just drag and drop such files into Origin in the future.
CP
|
 |
|
|
Topic  |
|