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 for Programming
 LabTalk Forum
 Opening Multiple Files in One Worksheet
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

kid

USA
20 Posts

Posted - 08/22/2001 :  10:30:58 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
I need to open several files, and they'r all in the same format, but I need to have each file's data in a different colunm in one spread sheet. If this turns out not to be posible, then is a way in LabTalk that i could look into a windows folder and count how many files of certain type there are?

I'm trying to write a fully atomated report generator.

Alex

CStorey

Canada
137 Posts

Posted - 08/22/2001 :  1:41:55 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
In Origin 6.1 you can choose to add the data from every file selected to a new column under the "Import Multi ASCII/Import Eac file as" drop down list.

Alternately this simple script should do the trick. The [FilenameCol] section is used to strip the filename from the PATH\FILENAME.EXT string.

[MInport1wks]

%L="C:\SHARED\exp_data_2001\low_temp\20010606\"; // Default directory for files
win -t wks Origin; // Create a worksheet with Next DataN Name
%W=%H; // Remember worksheet name for later
%W!wks.joinmode=0; // Set %W worksheet to append mode
delete %(%W,2); delete %(%W,1); // Remove Default columns


FDLOG.DlgName$="Import Files"; // Title Bar text
FDLog.Message$="All files will be added to 1 worksheet!"; // Comment text
FDLog.ShowComment=0;
FDLog.path$="%L"; // Set initial path
FDLog.numtypes=3;
FDLog.type1$=[DAT files]*.DAT; // Use wildcards in multiopen
FDLog.type2$=[TXT files]*.TXT;
FDLog.type3$=[All files]*.*;
FDLog.defType=1;
FDLog.multiOpen.sort=1; // Sort only Groups selected!

If(FDLog.MultiOpen()!=0/0)
{
Loop(mmm,1,FDLog.MultiOpen.Count)
{
newcol=%W!wks.ncols; // Get the number of columns in wks
FDLog.Get(A, mmm); // Get the filename to import
win -t wks origin wks$(mmm); // Temporary worksheet
open -w %A; // Open Next File in temp. wks.
%T=%H; // Remember the Wks name
#!type "File #$(mmm) - %A"; // Show File Name in Script window

win -o %T {Tcols=wks.ncols;}; // Count number of new columns
%W!wks.join(%T); // Add data to worksheet
win -c %T; // Close temporary wks

run.section(,FilenameCol); // Get filename from %A=path\filename.extension
/// Rename each added column with filename(colnumber).
Loop(nnn, 1, Tcols)
{
%W!wks.col$(newcol+nnn).name$="%B$(nnn)";
};
};
};
#!type "All file imported sucessfully.";

del -v mmm;
Return;

//////////////////////////////////////////////
// Grab the Filename and make a column Name //
//////////////////////////////////////////////
[FilenameCol]
fnpos=0;
pathlength=%[%A];
For(ijk=pathlength; ijk>0; ijk--)
{
If ("%[%A,ijk:ijk]"=="\")
{
fnpos=ijk; //position of "\"
ijk=-10; //end condition
};
};
//// Grab all chars after that - 3 ////
%B=%[%A,fnpos+1:pathlength-4];
#!Type "Name = %B";
Return;


Edited by - CStorey on 08/22/2001 14:03:54
Go to Top of Page

scottp

USA
60 Posts

Posted - 08/22/2001 :  2:41:52 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
You do not specify what version of Origin you currently are using. The following information is for the most recent version of Origin 6.X.

Origin allows you to import multiple ASCII data files into the same worksheet (as new columns), or into separate worksheets. I will outline the procedure for importing the data into a
single worksheet.

To import multiple ASCII data files into a single worksheet, select File: Import: Multiple ASCII , or click the Import Multiple ASCII button on the Standard toolbar when a worksheet is
active.

You can select the files that you wish to import. Make sure that you specify in the drop down list, Import each file as: "New Columns" before you click on [OK]. The first selected file
will be imported into the first columns of the Origin worksheet. Subsequent selected files will add each dataset as a new column in the same worksheet.

Since this is the LabTalk forum, you can access the select File: Import: Multiple ASCII with the following LabTalk code: run.section(file,MultiImportToolbar);

You can view the complete code by opening the file run.ogs
Go to Top of Page

Thomas83

24 Posts

Posted - 05/24/2013 :  01:55:12 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi.
Maybe this is a stupid question, but how can I open the run.ogs?
Regards
Go to Top of Page

greg

USA
1378 Posts

Posted - 06/13/2013 :  11:55:43 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
There is no file RUN.OGS. I think Scott meant to say FILE.OGS which is the name of the file being run by
run.section(file,MultiImportToolbar);
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