Generating data as a fixed-length record

Options

Is it possible to generate data as a fixed-length record?

I want to be able to export a list of Users and all of their information.
Each user would be on a separate line.

i.e.
Name (20 char)| DOB (10 char - dd/mm/yyyy)| Location (20 char) | Company (20 char)

Best Answer

  • Michael Udinski
    Michael Udinski Administrator

    ADMIN

    Answer ✓
    Options

    Hi @Rory - this is definitely possible in Xano.

    You're able to use filters like sprintf or Replace to perform variable text substitution. And then a filter like substr would let you extract the amount of characters you want per piece of data.

Answers

  • Rory
    Rory Member
    Options

    That's great, thanks Micheal.

    Just to complicate things a little more, is there any way to export or import .txt files as well?
    I will have to export my data as a text file to be imported by another system.

  • Michael Udinski
    Michael Udinski Administrator

    ADMIN

    Options

    Hmm not natively but tell me a little more about your use case. Maybe there's a solution we can point you to. The data you need to export as .txt is from your Xano database? And are importing to another system via an API call or exporting a file and manually importing?

  • Rory
    Rory Member
    Options

    I have to upload the text files to a government body and they only accept it in this format.
    I've attached an example for reference.


    With regards to importing, this is a common feature offered by competing platforms. It allows customers to transfer their existing data over to a new platform.

    Importing would require the removal of the blank spaces used in the fixed-length records.

  • Rory
    Rory Member
    Options

    Hi @Michael Udinski , were you able to think of a workaround for my issue?
    I forgot to mention earlier that the typical user workflows will be as follows:

    Exporting Data:

    - User filters a list of their company's data based on start & end dates.
    - User Exports the txt file with fixed length records.
    - User can then manually upload the txt file to the government website. (NB:This could be done with an API call in the future.)

    Importing Data:
    - User uploads the txt file to my app (WeWeb+Xano)
    - The fields will be cleaned up, removing unnecessary blank spaces from the fixed length records.
    - Data is then imported into Xano and includes User's details.

    I hope this isn't too big of an ask. Unfortunately, it's the core feature that I have to include in my app.
    Without it, my customers won't be compliant and I won't be able to sell to them.

    Thanks