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
Username:
Password:
Save Password
Forgot your Password? | Admin Options

 All Forums
 Origin Forum
 Origin Forum
 How to import many txt files to matrices?
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

lihao1978

USA
Posts

Posted - 10/23/2007 :  6:21:18 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Version (Select Help-->About Origin): 75sr6
Operating System:XPsp2

I have a lot of txt files need to be imported into matrices respectively. It is boring to import one by one by using the "Import ASCII..." especially when the file is large. Does anyone know how to import all the files one time? Or, I can import all the files into worksheets one time. But, who can help me to convert many worksheets into matrices efficiently? Thanks.

Mike Buess

USA
3037 Posts

Posted - 10/24/2007 :  10:43:56 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
If you can import a single file directly to matrix with the Import ASCII menu command then the following script will do the same from a multiple file selection dialog. You can run the script from the script window or Custom Routine button.

fdlog.UseGroup(Ascii); // use extensions .csv, .dat, .txt, .*
if( fdlog.MultiOpen()==0/0 ) break; // quit if dialog was cancelled
loop(ii, 1, fdlog.MultiOpen.Count)
{
fdlog.Get(A, ii); // set %A = next file name
win -t matrix; // create new matrix
open -w %A; // import file to matrix
set_ascii_import_page_info(%A); // save file name, path and date
matrix -pg Dim nCols nRows; // get # columns and rows
matrix -ps X 1 nCols; // set X range = 1 to nCols
matrix -ps Y 1 nRows; // set Y range = 1 to nRows
}

Mike Buess
Origin WebRing Member
Go to Top of Page

lihao1978

USA
Posts

Posted - 10/25/2007 :  11:14:40 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Mike, thank you so much. It really does work well!
Go to Top of Page
  Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000