The GAPTEQ components 'CSV importer' (**NEW since GAPTEQ 4.0**) can be used to import large amounts of data from a CSV file into a table.
In this article you will read the following content:
Import CSV file via drag & drop
The CSV importer component can be used to import large amounts of data from a CSV file into a table.
- Also suitable for larger amounts of data
- Multiple CSV files can be uploaded and imported using drag & drop
- Convenient mapping of CSV file and database table with initial auto-mapping function
- Secure import in transaction (undo in case of error) and configurable error handling
1. Place CSV importer component
- Drag and drop the CSV Importer component onto the page as usual and assign a data layer.
Note! The component needs the same data layer as the target table to which the data is to be imported so that the columns can be mapped / assigned correctly.
In the properties of the component, you can first select under the Save mode tab whether
- the imported data records are to be added to the target table (“Append”).
- all previously contained data records in the table should be deleted during import (“Overwrite”).
Please note! Pay careful attention to the selection under “Save mode”. If you select “Overwrite”, all data records in the table will be deleted during the import!
2. Import & configure CSV file
- Via the CSV Settings tab in the properties, you can now import and analyze the CSV file once so that the columns of the file can be mapped with the fields of the table in the next step.
- Read in the CSV file using the “Analyze a sample file” button and select your CSV file.
- Under “Column separators”, select the separator used in the CSV file
- Under “Encoding” select your desired encoding format (e.g. UTF-8, ANSI)
- Under “Escape char” select your escape character
- Finish the CSV settings by clicking on “Ok”. In the following pop-up window, select whether an automatic mapping from file to table should be created.
Note! Automatic mapping can only work if the field names of your CSV file are identical to the field names of the database table!
3. Create CSV mapping
- Use the CSV mapping tab in the properties to define the assignment of the CSV fields to the fields in your database under Operation.
Note! Fields that have already been automatically mapped have the “Map” operation. Alternatively, the database field can be assigned a fixed value (Fix value), a NULL value (zero) or excluded from import with Ignore.
4. Import CSV file via drag & drop
Now drag and drop one or more CSV files onto the CSV importer component or select the corresponding file via “Select file”.
Note! Don't forget to execute a corresponding refresh event on the target table (data grid) or to update the table using the manual refresh button so that the imported data records from your CSV file are displayed directly.
- If required, you can define actions that are to be executed in the event of an error (importError) or a successful import (fileImported):