Replacing column headers prior to file upload

Hi,

I want my users to import data into a data set to then use in other areas of the app.

I have a form where they can create the data set, select the source (in this case a csv file) and the ability to upload a file:

When the user clicks the add button to the bottom right, a pop up is shown where I display the column headers of the uploaded file in a repeating group to the left and a dropdown to the right where the user can choose the type of data that column is:

I then have a data type called ‘Data’ which has 15 Text Fields (‘Text Field 1’ to ‘Text Field 15’), 10 Number Fields (‘Number Field 1’ to ‘Number Field 10’) and 5 Date Fields (‘Date Field 1’ to ‘Date Field 5’) :

What I want to then happen is:

  • If the user selects "Number’ for Order ID, the import will use Number Field 1 for that column
  • If the user selects "Text’ for Customer Name, the import will use Text Field 1 for that column
  • If the user selects ‘Text’ for Product, the import will use Text Field 2 for that column
    etc etc.

I’m struggling with changing the uploaded file with the new headers so the import works.

Can anyone help me with this please?