OriginLab Corporation - Data Analysis and Graphing Software - 2D graphs, 3D graphs, Contour Plots, Statistical Charts, Data Exploration, Statistics, Curve Fitting, Signal Processing, and Peak Analysis     
Skip Navigation Links
All BooksExpand All Books
Origin HelpExpand Origin Help
Importing and Exporting DataExpand Importing and Exporting Data

6.5 Importing Data by Drag-and-Drop

You can import files by dropping them onto the Origin workspace, provided the key file handling components are in place. Origin ships with built-in drag-and-drop support for selected file types and you have the option -- by creating an import filter with the Origin Import Wizard -- to add drag-and-drop support for additional file types. This topic summarizes the basic things that you ought to know to make use of drag-and-drop file import.

Note: Please make sure that you do NOT run Origin as an administrator.

Import code reading sequence

When files are dropped into Origin, they are handled by one of two import routines.

  • The older method involves calling a LabTalk section in a file called DOFILE.OGS. This user-modifiable file is installed in the Origin program folder as part of your Origin software. This method is supported primarily to ensure backward-compatibility.
  • The newer (and preferred) method relies on an Origin import filter that you create using the Import Wizard. Origin ships with a number of built-in filters, which have been saved as .OIF files in the \Filters folder of your Origin program folder.

When files are dropped into the Origin workspace, Origin does the following:

  1. Origin looks into the Origin program folder for a file called DOFILE.OGS. It then looks for a section named [OnOpenExtension], where Extension is the file extension of the dropped file. If found, that section is executed and the file name is passed as an argument.
  2. If DOFILE.OGS contains no file handling instructions for file type Extension, Origin looks for an appropriate import filter. For file types with built-in drag-and-drop support, these OIF files are stored in the Origin program's \Filters folder. User-created filters can be saved in various locations. If multiple appropriate filters are found, a dialog opens to let you pick the most appropriate filter.
  3. If an appropriate import filter is not found, the Import Wizard opens. This gives you the opportunity to interactively parse the file, extract file information and, if so desired, save the settings as an import filter.

Origin Import Filters

Origin Import Filters are created with the Import Wizard. When creating an import filter with the Import Wizard, the normal sequence of events is to open the Import Wizard, select a data file, then step through a sequence of Wizard pages in which you interactively parse the file, select file and window naming options, select header information to be stored and re-used, etc. When you have finalized your import settings, you can store them as an import filter (saving the filter is highly recommended if you plan to import the same or similar files in the future).

When creating an import filter, you have the option of (1) saving the filter with an Origin child window or (2) you can save the filter to a separate Origin Import Filter file (.OIF). The only real advantage to saving the filter with the child window is that the filter travels with the window itself and, thus, it becomes part of the Origin project file (OPJ) or child window file. The other option -- saving the filter as a separate .OIF file -- allows you to select the filter on the first page of the Import Wizard, then click Finish (the filter contains all necessary import instructions). Both child window-based filters and OIF files support drag-and-drop file import.

Another benefit of creating an import filter is that once created, the filter can be tweaked to import files that vary somewhat in their structure, without having to completely recreate every import specification. Filters are easily shared with colleagues, allowing standardization of import file handling among different work groups or geographically remote work sites.

Once defined, your import filter can be narrowly targeted to work only with, say, a particular file name (or variations on that file name) or it can be broadly targeted by specifying that it apply to all files with a particular file extension. For instance, you might work with an instrument that automatically names data files in sequence using a scheme something like XYZ_001.CSV, XYZ_002.CSV, XYZ_003.CSV. Using the "*" wildcard character, you could target the filter at all .CSV files in your data file folder by specifying that the filter apply to any file with the name "*.CSV." Conversely, you could narrowly target the filter by specifying that the filter apply only to CSV files named "XYZ*.CSV."

Target Windows and Target Window Templates

When defining an import filter for ASCII, binary or user-defined file types, you must specify a Target Window and Target Window Template. Note that Data Types other than User-Defined are limited to Target Window = Workbook. Note, too that User-Defined allows you to bypass specifying the Target Window and Target Window Template if window creation is to be handled by your Origin C code (in which case, the code would handle window creation).

The Target Window merely specifies the type of child window that will receive the imported data. The Target Window Template, on the other hand, is a specific (named) window template with custom configuration and format settings. The Target Window Template is used when drag-and-drop import operations call for creating new windows.

Assuming that you have defined an import filter, if you drag-and-drop one or more data files into an active window and that window is of the Target Window type, then Origin will import the file(s) using the new window/new worksheet/new column settings specified in the filter. If, for instance, (1) the filter Import Mode is set to Start New Columns and (2) the file(s) are dropped onto a workbook window (the Target Window type specified in the filter), then the file(s) are imported and added as columns into the active worksheet in the active workbook. If the active sheet had empty columns, they would be filled first. In this case, the active workbook was of the correct Target Window type and each file required only the creation of new columns. No new windows needed to be created so, therefore, the Target Window Template was not used.

If the filter Import Mode had been set to Start New Books, then the first file dropped would import into the active workbook if the columns in the active sheet were empty (again -- the Target Window was of the correct type), and each subsequent file would import into new workbook windows created using the Target Window Template. Note that the Target Window Template may, or may not, be the same template that the active workbook window was based upon. However, the default Target Window Template (<Default> from the drop-down list on the Import Wizard Source page) is the default Origin worksheet or matrix template. Unless you have chosen a different default template, this would be ORIGIN.OTW (worksheet) or ORIGIN.OTM (matrix).

Built-in drag-and-drop support

All third-party file types that have build-in support are importable by drag-and-drop, owing to the fact that import filters for these file types are built into Origin. You can use the Filter Manager to specify whether the drag-and-drop import mode should be turned on/off for a specific file type. The Filter Manager can be opened by selecting Tools: Import Filter Manager from the Origin menu.

Adding drag-and-drop support for new files

You can add drag-and-drop support for new files by defining an import filter using the Import Wizard. You will need a representative data file and you should know something about the type of data that your file contains (whether it contains ASCII or binary data, or is of another type).

Some things to consider when deciding how to target your import filter and where to save it:

  • When you drag-and-drop one or more files into Origin, Origin first searches a file called DOFILE.OGS to see whether there are data handling instructions for the dropped data file (see "Import code reading sequence," above). If Origin fails to find data handling instructions for the dropped file in DOFILE.OGS, it searches these locations, in the following order, for an appropriate import filter: active child window > data file folder > User Files \Filters folder > Origin program \Filters folder. If the files are dropped into an empty portion of the workspace, there is no active child window and so the search goes directly to the data file folder > User Files \Filters > Origin program \Filters folder.
  • If multiple applicable filters are found in one of these locations, Origin prompts you to select a filter from Select Filter dialog box (Note that when saving filters with the child window, you can only save one per window). If no applicable filter is found, Origin opens the Import Wizard. You then have the opportunity to create and save an import filter.
Drag and Drop Basics-1.png
  • If your data file isn't of the ASCII or simple binary types, you can still create filters by supplying data handling instructions in the form of Origin C code.
  • Drag-and-drop import supports multi-file import.

© OriginLab Corporation. All rights reserved.