|
DatabaseImport
Imports data from a file into a table.
long DatabaseImport(
|
Parameters
database
[in] Database handle received in DatabaseOpen().
table
[in] Name of a table the data from a file is to be added to.
filename
[in] CSV file or ZIP archive for reading data. The name may contain subdirectories and is set relative to the MQL5\Files folder.
flags
[in] Combination of flags from the ENUM_DATABASE_IMPORT_FLAGS enumeration.
separator
[in] Data separator in CSV file.
skip_rows
[in] Number of initial strings to be skipped when reading data from the file.
skip_comments
[in] String of characters for designating strings as comments. If any character from skip_comments is detected at the beginning of a string, such a string is considered a comment and is not imported.
Return Value
Return the number of imported strings or -1 in case of an error. To get the error code, use GetLastError(), the possible responses are:
Note
If there is no table named table, it is generated automatically. Names and field types in the created table are defined automatically based on the file data.
If there is no table named table, it is generated automatically. Names and field types in the created table are defined automatically based on the file data.
ID |
Description |
---|---|
DATABASE_IMPORT_HEADER |
The first line contains the names of the table fields |
DATABASE_IMPORT_CRLF |
CRLF (the default is LF) is considered a string break |
DATABASE_IMPORT_APPEND |
Add data to the end of an existing table |
DATABASE_IMPORT_QUOTED_STRINGS |
String values enclosed in double quotes |
DATABASE_IMPORT_COMMON_FOLDER |
The file is stored in the common folder of all client terminals \Terminal\Common\File. |
Example of reading the table from the file created by the code from the DatabaseExport example:
//+------------------------------------------------------------------+
|
See also