Importing CSV and Excel files into the application

Importing CSV and Excel files into the application

When the application is created and launched, it is periodically necessary to import information into its database from files. Of course, the databases will also be replenished automatically - due to information added by users or provided by integrated services. But it is better to add import settings for common CSV, XLS, or XLSX formats in advance - most likely, they will be useful to you and will greatly simplify your work in the future.

Today we will talk about setting up import on the no-code platform AppMaster.io in two versions:

  1. Static: when the order of the columns in the loaded tables is constant.
  2. Dynamic: when the order of columns in tables is changed.


At the end of the article, there is a video with examples and an explanation of all the configuration steps.

File import setup process

The development of such functionality is not much different from classical programming, but with the help of visual tools, you will do it much faster. To do this, you need to follow 5 simple steps:

  1. Prepare test files for import: no matter in which extension, the setup for CSV and Excel formats will look the same.
  2. Customize a custom business process using the building blocks provided by the editor - no additional modules need to be downloaded.
  3. Create a new endpoint for a business process - to implement the functionality of loading an imported file in a web application.
  4. Add a form to the web application page that will upload CSV and Excel files and report a successful import or display an error message.
  5. Test the functionality using test files to make sure everything works correctly.

If you already have experience with AppMaster.io or other no-code platforms, then set up is unlikely to take more than an hour, even taking into account watching the tutorial video.

Necessary blocks of business processes

Many of them are analogs of classical programming functions - only in the form of visual tools, with which you will work on the drag & drop principle.

Here is a list of the main blocks for setting up import with their brief description.

* In addition to them, you may also need various auxiliary blocks: if, when processing values from a file, you need to convert data from one format to another, save a variable for further processing, concatenate or split strings.

Static import

In this case, you do not need to specify the names of the columns, but their order must be the same in all loaded files - otherwise, the program will import data incorrectly.

  • Start - is a building block that will accept the imported file for reading (after adding the corresponding variable to it).
  • Read CSV File, Read XLS File, or Read XLSX File - reads the downloaded file line by line.
  • For each loop - a loop that will iterate over all columns in each row for subsequent processing of their values.
  • Switch - to split the stream: to configure various parameters for processing the values ​​obtained from the imported file, based on their indices.
  • Make and Create blocks from the Model Functions group - for the data model that you will use when creating and saving objects from the imported file; and into which, accordingly, you will add the values ​​obtained in the previous stages.
  • End - is a building block that ends a business process after all data has been successfully imported into your application database.

Dynamic import

In this case, the columns in the loaded files can be in any order, but their names must always be the same for the import to be successful.

To set up dynamic import, you need to add analysis blocks for the first row of the table - to determine which data is contained in each of the columns of the loaded file.

  • Equal - is a comparison operator that will determine if the processed string is the first one.
  • If-Else - which will take a value from Equal and redirect the stream depending on that.
  • An additional For each loop block -#nbsp; is a loop that will only work on the first row (that is, with the column names).
  • Append Array - Will save all values ​​obtained from the first line of the file to an array.
  • Array Element - Retrieves the values ​​of specific elements from the Append Array along with their indices from the For each loop (the one that processes all the lines).
  • You also need to change the Switch block so that it redirects the stream and processes the imported data depending on the values ​​received from the Array Element.

Endpoint creation

When adding an endpoint, select the POST method, write down the URL and specify the created business process - the minimum setup is complete. Additional information on how to define access rights for user groups or from different IPs can be found in the platform documentation (EN and RU versions).


File upload form

For the import form to work correctly, you need to select Create Record when creating it and specify the created endpoint, as well as add a form confirmation button (trigger - onClick, action - Submit form).

Video: Example of Configuring CSV File Import

This video describes in detail all the steps for setting up static and dynamic imports using a CSV file as an example.

VIDEO - AppMaster.io How-To: Import CSV/Excel File

Would you like to chat directly with our developers and other no coders? Join the Appmaster.io Telegram community. We will be glad to answer your questions!

GET STARTED RIGHT NOW

Inspired to try this yourself?

The best way to understand the power of AppMaster.io is to see it for yourself. Make your own application in minutes with 14-days trial plan

Bring Your Ideas to Life