Author |
Topic |
|
galinaphysics
Israel
2 Posts |
Posted - 07/04/2012 : 05:51:18 AM
|
In the previous version OriginPro 7.5 I could read the file line by line opened with the help of a simple script:
getfile -m *.asc *.dat; getfile -g 1; open -w %A; hfile=file.open(%A); file.lread(M,hfile); Some statements, I dropped. Then I could analyze this line and get the right information. In OriginPro 8.5.1 this script does not work, because there is no method of lread(). How can I solve this problem? Thank you in advance |
|
asp
USA
17 Posts |
Posted - 07/04/2012 : 11:17:18 AM
|
Obviously lread is obsolete. Why not try to use impasc x-function. I use the following script (for my data which structure is known):
dlgfile g:=*.csv; impasc options.ImpMode:=3 Options.FileStruct.DataStruct:=1 Options.FileStruct.Delimiter :=1 options.Sparklines:=1 options.Names.AutoNames:=0 options.Cols.NumCols:=5; |
|
|
galinaphysics
Israel
2 Posts |
Posted - 07/11/2012 : 09:35:52 AM
|
ASP, thanks, but your script does not give the ability to read line by line information from the text part of the file, and use it later in the processing of data (eg - temperature and magnetic field are recorded in the second line of text file to be opened, and numeric data begin with the 50th row). I do not need any other information from the text of the file and I do not want to see in the header of each column of some words and numbers. Files a lot and I have no way to open each file.
|
|
|
greg
USA
1378 Posts |
Posted - 07/11/2012 : 1:11:14 PM
|
This all still works, but your fragment does not do anything but import one file.
Here is your fragment fully commented:
getfile -m *.asc *.dat; // This gets MULTIPLE files getfile -g 1; // This only looks at the FIRST file open -w %A; // This IMPORTS that file hfile=file.open(%A); // This OPENS the file for processing file.lread(M,hfile); // This reads a line into %M
Here is a more complete sample:
getfile -m *.asc *.dat; // This will set count = number of files selected loop(ii,1,count) { if(ii!=1) newsheet; getfile -g ii; // This puts the 'iith' file into %A open -w %A; // This imports that file newsheet; hfile = file.open(%A); // This re-opens the file for processing size = file.size(); for( pos = 0, row = 1 ; pos < size ; row++) { file.lread(M,hfile); // This reads a line into %M; string str$ = %M; // Use string for new methods numTokens = str.GetNumTokens(); if(numTokens > wks.ncols) wo -a numTokens - wks.ncols; for( idx = 1 ; idx <= numTokens ; idx++ ) { wcol(idx)[row]$ = str.GetToken(idx)$; } pos = file.getpos(); } file.close(); }
which reads each selected file twice : first as ASCII import, then reading file line by line (so two sheets each). |
|
|
|
Topic |
|