Importing a CSV file to populate a database

0
Question:I'm building a new AssetControl app to replace our current outdated one. I need to migrate data from the old app to populate the new database.Context:I can export the old app's data as a CSV file. I attempted to use the DataImporter module but ran into issues. I'm still learning Mendix and would appreciate guidance on the best way to handle this migration.What I need:Clear steps on how to import CSV data into my new app, or suggestions if there's a better approach than using DataImporter.
asked
2 answers
1

Hi Igor Santana 


 You can use data importer , csv module and excel importer to import data.


Option 1: Data Importer

The Data Importer is available in Studio Pro 10.6 and above and allows you to import data from Excel or CSV files. You can choose which columns to import, preview the data, and create a non-persistable entity (NPE) in your domain model that corresponds to your input.

Step-by-step:

Step 1 — Install & Set Up Download the Data Importer extension from the Marketplace and add it to your app. This module also requires a File Document (see File Manager).

Step 2 — Create the Data Importer Document Right-click the module you want to add the Data Importer document to and click Add other > Data Importer. Name the document, then click OK.

Step 3 — Configure Your CSV Click Select a local file to select your CSV. Configure the four key settings: Delimiter (comma, semicolon, pipe, or tab — default is comma), Quote Characters (single or double — default is double), Escape Characters, and whether a header row is already included.

Step 4 — Map Columns to Entities Click Preview Source Data & Entity to view the data. You can edit the entity — change the entity name, rename attributes (Original Name vs Attribute Name), and change data types via a dropdown.

Step 5 — Wire Up the Microflow Use the "Import data from file" activity in a microflow — found under Integration Activities in the Toolbox. Set the File input to your FileDocument object and set the Data Importer Document to the one you created. You can capture the result in a return variable for further processing.

Step 6 — Persist the Data The NPE holds your imported rows in memory. You then loop over the list, create your actual persistable AssetControl entities, map the attributes, and commit — this is where your migration logic lives. 


if you face any issue in implemetation post here. I can help

answered
0

Para importar tus datos de manera más robusta, olvídate del DataImporter y mejor utiliza el módulo Excel Importer en combinación con MxModelReflection, ambos gratuitos en el Marketplace de Mendix. La estrategia es sencilla: instalas ambos módulos, ejecutas el MxModelReflection para que la aplicación reconozca la estructura de tu nueva base de datos, y luego configuras un Template dentro de la interfaz del Excel Importer para mapear exactamente las columnas de tu archivo CSV hacia los atributos de tus entidades en AssetControl; este es el flujo estándar de la comunidad para migraciones, te dará mucho más control sobre la data y te evitará dolores de cabeza si haces la prueba inicial subiendo un archivo con solo un par de registros para asegurar que el mapeo funcione a la primera.

answered