Download as CSV using the xano snippet endpoint

Options

I have an array with several objects that I would like to download as a CSV.

On review I noticed some objects don't have all the fields. They seem to be missing the same field.

I've been using xano for a month or so now and I continue to be impressed by the functionality. It looks to me like there must be a way to Add a field with a null value to each object that is missing the field perhaps using a push and a for each loop?

Best Answer

  • Liz Anaya
    Liz Anaya Member, Administrator

    ADMIN

    edited July 2023 Answer βœ“
    Options

    You can use the set filter to add or update a property in your object. Here is an example:

    Let me know if this helps. πŸ˜„

Answers

  • Liz Anaya
    Liz Anaya Member, Administrator

    ADMIN

    Options

    Hi @enyarick!

    You are on the right track! A way that you could add a field with a null value to each object that is missing the field would be to implement a conditional within a for each loop to check if the data you are looking for exists and edit the object if it doesn't. Once your function stack has gone through this process, you can create the CSV file following the steps from the Snippet.

    Let me know if this is helpful or if you have any additional questions. 😊

  • enyarick
    enyarick Member ✭
    Options

    Thanks @Liz Anaya!

    Would adding a field be to use a set filter where the field doesn't exist and use the path as that missing field?

  • enyarick
    enyarick Member ✭
    Options

    This is amazing @Liz Anaya! Thanks so much. I was sure there must be some way to achieve this.