0

custom .csv export

Hi   - I'm  attaching a current copy of my DB (with fake data) with 95% of the user interface built and working. One of the last things for me to do is to create a .csv export from the user interface that pulls from our Contacts table (without users actually interacting with the Contacts table) to import into Mailchimp. If you go to the creatively named "Mailchimp Export" table, you'll see a button with a script I cobbled together with help from Ninox docs and the Ninox by U ChatGPT you pointed me at awhile ago. The script seems to run ok - the text box to the right of the button is the csv output, which I was hoping to simply copy and then use Mailchimp's import to paste into our audience. My issue is the \N that Ninox pushes out as a "CRLF". While ChatGPT recognizes the \N, nothing else seems to. I haven't yet tried pasting into Mailchimp (don't want to blow up the audience that's already there), but Numbers and Excel don't recognize the \N as a line-ending character. (see attached screen shot with ChatGPT's explanation of the output. I'm stumped - can you help me sort this out?

(As an aside, I have a couple of scripts that generate emails that also use the \N as a "CRLF" and none of the email clients I've used properly interpret \N either)

2 replies

null
    • Fred
    • 7 days ago
    • Reported - view

    In Ninox if you want to insert a carriage return then you can easily just put a carriage return inside " ".

    "// Export contacts where 'Receives Emails?' = Yes;";
    let contacts := (select Contacts where 'Receives Emails?' = true);
    let csv := "Lastname,Firstname,Email,Member" + "
    ";
    csv := csv +
        join(contacts.(Lastname + "," + Firstname + "," + Email + "," + if Member then "Yes" else "No" end), "
    ");
    this.('CSV Output' := csv)
    

    But that makes the code hard to read.

    So you can do the following:

    "// Export contacts where 'Receives Emails?' = Yes;";
    let contacts := (select Contacts where 'Receives Emails?' = true);
    let xlf := urlDecode("%0A");
    let csv := "Lastname,Firstname,Email,Member" + xlf;
    csv := csv +
        join(contacts.(Lastname + "," + Firstname + "," + Email + "," + if Member then "Yes" else "No" end), xlf);
    this.('CSV Output' := csv)

    Line 3, we use the urlDecode() command to put the carriage return into a variable.

    Then you can reference the variable, like in line 4 and line 6.

    The end result is:

      • Dave_Airel
      • 6 days ago
      • Reported - view

      Thanks,  as always really helpful. Much appreciated.

Content aside

  • Status Answered
  • 6 days agoLast active
  • 2Replies
  • 34Views
  • 2 Following