I have some data in a text file. I would like to retrieve the values and put them into a worksheet for plotting.
The text file layout is currently set to that of an INI file so I can use the ini.getstr command for value retrieval.
I would like to know if there is an easier way to put the values into a worksheet before I start using loops and the above command etc.
I can set the text file to be of any layout but it is desireable to have headings etc as opposed to raw data. If necessary I could generate two data files with one being raw data in a format that Origin can interpret.
I think you'll find that reading data values in a loop will be painfully slow. Origin's standard method of importing columnar data is much faster. But there's no reason you can't combine an ini-type header and columnar data in the same file.
1) Create a custom wks template with the proper ASCII Options (e.g., number of columns, column separator, number of lines to skip (header size), etc.). Then import with these commands...
win -t D MyTemplate; // create a wks from your template %Z=file path\name; open -w %Z; // import file
2) Use the Ascimport object's properties and methods, e.g., ...
win -t D; // create wks from default template Ascimport.GetSettings(); // get its ASCII import settings Ascimport.numcolumns=4; // reset # of columns Ascimport.delimiter=3; // columns are separated by spaces Ascimport.headerlines=16; // 16 lines in header Ascimport.FileName$=file path\name; Ascimport.WriteSettings(); // save settings to wks Ascimport.Import(); // import file
Look for Ascimport details in LabTalk's Object Reference. (A similar method is available in Origin C.)