Data: Connect Multiple Files
Connect to multiple data files
Minimum Origin Version Required: 2020b
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;
| 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 |
|
Specify the source of files to be imported. Two options are available:
|
| File Names | fname |
Input string |
|
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 |
|
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 |
|
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:
|
| Insert File Name | addfn |
Input int |
|
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 |
|
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:
|
| 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 | |
| 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 |
|
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,
|
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.