The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
 All Forums
 Origin Forum for Programming
 LabTalk Forum
 Import ASCII file

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

Screensize:
UserName:
Password:
Anti-Spam Code:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkUpload FileInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
galinaphysics 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
3   L A T E S T    R E P L I E S    (Newest First)
greg 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).
galinaphysics 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.

asp 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;

The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000