2.7.23 files2dc


Menu Information

Data: Connect Multiple Files

Brief Information

Connect to multiple data files

Additional Information

Minimum Origin Version Required: 2020b

Command Line Usage

1. string fname$="C:\examples\Gasoline 1.mat%(CRLF)C:\examples\Gasoline 2.mat%(CRLF)C:\examples\Gasoline 3.mat"; files2dc dc:=MATLAB;

2. files2dc dc:=CSV fname:="%Ytest2.csv%(CRLF)%Ytest1.csv" samebk:=1 dlg:=1;

3. files2dc dc:=CSV src:=1 path:=%YData samebk:=1;

4. files2dc dc:="Import Filter" fname:="%YS32-014-04.dat%(CRLF)%YS21-235-07.dat%(CRLF)%YS15-125-03.dat" samebk:=1;

Variables

Display
Name
Variable
Name
I/O
and
Type
Default
Value
Description
Data Connector dc

Input

string

Specify the file type of Data Connector you want to use to connect to data files. Multiple types are supported, e.g. Biologic, TDMS, XML,MATLAB, HDF, CSV, Excel, and you can also choose to import files by specified filter.
Source src

Input

int

0
Specify the source of files to be imported. Two options are available:
  • 0:Specified Files: specify files to import in File Name below
  • 1:Files in Specified Folder: search in Folder (specified below) and import all files of data type specified in Data Connector
File Names fname

Input

string

fname$
Availabel when Source = Specified Files. Specify the files to be imported. Full path should be included.
Folder path

Input

string

Availabel when Source = Files in Specified Folder. Specify the folder path.
Same Book samebk

Input

int

0
Available if the selected Connector type supports importing multiple files in the same workbook, CSV Connector for example. Checking this checkbox means that the book is named with the name of the first file. If imported to separate books, each book will be name with the file name.
Append to Same Sheet samesheet

Input

int

0
Available if Data Connector = CSV and Same Book is checked. Specify whether to import multiple files into the same worksheet and if yes, how to append the files. Three options are available:
  • 0:None: import each file to a separated sheet,
  • 1:As New Rows: import all files in the same sheet appending by rows,
  • 2:As New Column: import all files in the same sheet appending by columns.
Insert File Name addfn

Input

int

0
Available when Append to Same Sheet = As New Row. Check this checkbox to insert a column to the very beginning to store the file name information.
File Name Option filename

Input

int

0
Availble when Append to Same Sheet = As New Row/As New Column. Specify what information you want to extract from the file name. Three options are available:
  • 0:File Name Only: extract file name only, without file extension
  • 1:Name and Extension: extract both file name and extension
  • 2:Partial File Name: extract part of file name, and specify which part of the name to extract in Extract Part of File Name edit box below.
Extract Part of File Name parts

Input

String

When File Name Option = Partial File Name, specify which part of the file name to extract to the 1st column. Enter the character range in the form of From_Position:To_Position or From_Position+Count_Character_No. 1 refers to the first character and 0 the last one.

For example, suppose the import file name (with extension) is T325K.csv. To extract the temperature (including unit), that is, 325K, you can enter 2:0, or 2+4.

Partial File Name Label label

Input

String

Specify the file name column Long Name when Append to Same Sheet = As New Row, or label row header when Append to Same Sheet = As New Column.
Open Dialog for First File dlg

Input

int

0
If you want to specify the import settings, check this checkbox to open the Import Options dialog before importing the first file. All remaining files will follow these settings.
Set Column Designations cols

Input

String

Specify the column designations on import. Refer to this document for the designation symbols used here. Note that repeated patterns (pattern enclosed in parentheses is repeated) and pattern with lading and trailing designation symbols are supported.

For example,
XY will set 1st column as X and 2nd column as Y. It didn’t set designations further on so the rest of the columns will be all Ys;
3(XY) will set the first 6 column as XYXYXY. If there are more than 6 columns in the worksheet, the rest will be all Ys;
N(XY) will set 1st column as no designation, then repeat XY pair for remaining columns;
NL(XY)Z will et 1st column as no designation, 2nd column as label, last column as Z, the middle columns will repeat XY pairs.

Description

This X-Function is used to connect to multiple files at a time. Currently limited connector types are supported: CSV, Excel, MATLAB, HDF, NetCDF Connectors, and Import Filter for workbook; Matlab, HDF, and NetCDF Connectors for matrix.

The dialog supports choosing specified files or all files in a specified folder. For some types like the CSV Connector, you can specify the import of multiple files into the same workbook. If you select Open Dialog for First File checkbox, the Import Options dialog will be opened allowing you to specify the import settings. All remaining files will follow these settings.

Refer to this document for more information.