T O P I C R E V I E W |
Verde |
Posted - 12/15/2009 : 2:35:57 PM OriginPro 8 SR0 Windows XP
Hope someone help me in the following: I need to import multiple ASCII files into one workbook and have the files in separate worksheets. The data have the following format, with varying number of header lines:
C and G x Vg Sample=T45 Date= 8 Dec 2009 Npoints= 21 Ncol= 2 Nconst= 3 B (T)= 0 T (K)= 77 F (kHz)= .133 Note: This is a comment ............................................ Vg (V), C (F), G (S) 20, 3.24E-11, 697000 19, 2.7E-11,-2.E+6 18, 2.63E-11,-2.E+6 etc
In the header lines, Ncol= number of Y columns, Nconst=number of variables specified in the lines that follow. Then I would like to have the data plottted in separate graphs: Y1 vs. X and Y2 vs. X, etc. In each graph the variables in the header lines are to be used as a legend for each plot.
As the number of header lines can vary for each file, I cannot use the Import wizard. Any suggestion of a script/Labtalk/OC for this. I'm trying to learn to program, but still am a beginner. Thanks for any help |
4 L A T E S T R E P L I E S (Newest First) |
larry_lan |
Posted - 12/17/2009 : 9:51:26 PM Hi Verde:
So you have no problem to import data, right? Now the problem we met is how to extract header information to graph legend.
First of all, everything in the data file will not lost, you can see more information from Workbook Organizer. For example, I after importing, I can see file headers from here:
Then we can use these information. There is an X-Function called impinfo which will put these information into a tree variable. Then we can extract header information from the tree to a string variable, and write some script to update legends after importing.
Here is a script example. Please modify it as you need
// Get import information
impinfo trinfo := tt;
// Put the header info into a string variable
string strHeader$ = tt.header$;
// Count the number of tokens in the string , which seperated by "new line"
int nTokens = strHeader.GetNumTokens(LF);
if(nTokens < 6)
{
ty "Please check your file structure";
break;
}
// New legend text
string newLegend$;
// Trim the leading lines
for(int ii = 7; ii <= nTokens; ii++)
{
newLegend$ = newLegend$ + strHeader.GetToken(ii, LF)$ + "%(LF)";
}
newLegend.trimright(LF);
// Plot the last column
plotxy $(wks.ncols) plot:=200;
// Update Legend
legend.text$ = newLegend$; If you have any other problems, please feel free to contract us.
Thanks Larry OriginLab Technical Services |
larry_lan |
Posted - 12/17/2009 : 02:42:09 AM Hi:
Could you please send me some, maybe 4 or 5 files, sample data, then we can look into it to see whether we can find some rules?
Thanks Larry |
Verde |
Posted - 12/16/2009 : 06:33:03 AM Larry, thanks for your prompt reply. I've managed to use the import wizard for a few files, but I need to repeat this with tons of data which have different number of header lines. And as I said earlier, I would like to put the header lines that follow Nconst (B (T)= 0, T (K)= 77, F (kHz)= .133) in the legend of the graphs. However, the number of these lines (=NConst) may vary for each data file. Is there a simple way to extract the information in these specific header lines and put them in the graphic legend? Sorry, if these look like dumb questions and thanks a lot for the hints... I'm looking at the information and trying to follow them. |
larry_lan |
Posted - 12/15/2009 : 8:27:25 PM Hi:
I think either Import Wizard and Impart ASCII can auto detect correct column name and data in your case, and it works fine for vary headlines, please make sure to check Auto determine subheader line during importing.
Then you can put some script to the Import Wizard Advanced Options page to plot graphs after importing. Please read this page for more information.
In this Advanced Options page, you can use the plotxy X-Function to create your plots.
Thanks Larry OriginLab Technical Services |
|
|