Examples to understand the use of name
,
pattern
and prefix
.
For simplicity, this ignores the file location details.
Consider a directory with the name input
,
containing 204 files with filenames as follows:
100 files with names in a sequence from
file00.tbl
tofile99.tbl
.104 files with names in a sequence from
fileaa.tbl
tofileaz.tbl
,fileba.tbl
tofilebz.tbl
,fileca.tbl
tofilecz.tbl
, andfileda.tbl
tofiledz.tbl
.
To load all 204 files from the input
directory, using a prefix
:
"file": [{"prefix": "input/"}]
To load individual files that do not fit into a convenient
sequence, using one or more specific filenames and their
directories in the name
parameter:
"file": [{"name": "input/file25.tbl"}, {"name": "input/fileck.tbl"}]
To load specific file name sequences, using a regular
expression pattern
:
The regular expression syntax states that certain characters require an escape character, see: Regular Expression Syntax.
The escape character is the backslash character, and it is a
reserved character in both JSON
and
MySQL
. Therefore, it is necessary to
escape the backslash character twice, and specify
\\
for JSON
, and
\\
for MySQL
.
However, the regular expression escape sequence depends upon
the NO_BACKSLASH_ESCAPES
SQL mode:
Use
\\.
to escape a period ifNO_BACKSLASH_ESCAPES
is enabled.Use
\\\\.
to escape a period ifNO_BACKSLASH_ESCAPES
is not enabled. The following examples use this sequence because it is the default mode.
To load all 100 files with a numeric suffix:
"file": [{"pattern" : "input/file\\\\d+\\\\.tbl"}]
To load all 104 files with an alphabetical suffix:
"file": [{"pattern" : "input/file[a-z]+\\\\.tbl"}]
To load 10 files with sequence,
file00.tbl
, file10.tbl
... file90.tbl
:
"file": [{"pattern" : "input/file\\\\d0\\\\.tbl"}]
To load 24 files with sequence,
fileaa.tbl
to
fileaf.tbl
, fileba.tbl
to filebf.tbl
,
fileca.tbl
to
filecf.tbl
, and
fileda.tbl
to
filedf.tbl
,
"file": [{"pattern" : "input/file[a-d][a-f]\\\\.tbl"}]