Download CSV with special characters

Hi,
I am trying do use the action “Download CSV” to create a CSV. The issue that I am having is that data is multi-language, so it can occur in multiple different special characters that when file is downloaded, they don’t keep the format (format de/encoding issues I assume).

Example:
Polish: “Szkoła” comes in the CSV as: SzkoÅ.

How to keep the same format when downloading into CSV? Thank you very much.

Hi @WeeeeeWeb

Which program are you using to open the CSV file? Excel? Have you tried adding a BOM character (\ufeff) to your array?

Hi,
Using regular Excel. If I open the file normally, it does not open well. If I use the “Get CSV” within excel, it works properly.

I didn’t try that yet. I did try to enforce the encoding to UTF-8 from the xano output.

I’m having issues with this as well.

In Supabase I have an edge function that returns the data I want, which includes many characters with diacritics. I have yet to find a way to get this data downloaded correctly.

I’ve tried two different edge functions, one returning just a JSON array of data:

return new Response(JSON.stringify(rows), {
      status: 200,
      headers: {
        "Content-Type": "application/json; charset=utf-8",
...

and one returning CSV text:

 const csv = stringify(rows);
    const csvWithBOM = '\uFEFF' + csv;

    return new Response(csvWithBOM, {
      status: 200,
      headers: {
        "Content-Type": "text/csv; charset=utf-8",
        "Content-Disposition": "attachment; filename=envelope_addresses.csv",
...

In each case, I use the “download data as csv” workflow action for the response.

With the JSON array edge function, no matter what I try to tweak on the supabase side, the resulting CSV file always has formatting issues with the diacritics (for this workflow action I just have the ‘Action.result’ in the ‘data’ formula). All the data is in the file, but its full of things like:

S√£o Paulo
México

When I use the “download data as csv” workflow action with the csv format edge function, the data function for this step is, as described in the weweb docs,:

split(Action.result,',,')

But this results in a file with only a tiny piece of the data the function returned (I can see some of the missing data in the weweb log), there are only two rows (the header and one with four words of data), and everything is in one column (instead of over an expected 7 columns). That data seems, however, to be correctly respecting diacritics.

Anyone solved this issue or have a suggestion on what to try next?

Thanks!

I should note: I can get it to work if I push everything into Supabase (generate the CSV file in the edge function, have it save the file to Supabase storage, return a link to the file to Weweb, then use the “download file from URL” workflow action to download the file from supabase storage).

But ideally there would be better handeling/processing on the weweb side, as I have to add a lot of complexity to the edge function to store, serve, track, and later remove that file (compared to being able to just download the CSV from the weweb workflow).

When your using your split action are you getting an array of more then 2 returned? if you have just 2 then change from ‘,‘ to ‘,‘ in there example they just happen to have there csv data separated by double commas which is not very normal. But it shows that with there download as csv plugin you can have commas in your downloaded comma separated values ie csv.

Hi Sam,

Thanks for your tip.

I played around more with the specific split formula and can get the data on separate lines by splitting on the new line character, but this does not separate data into individual columns–each row is just one column.

A lot of the variations I tried on the ‘download as csv’ data formula result in an error:

So I managed to get the data halfway there: into their correct rows, but not into proper columns. The exact formula is below.

Secondly, the diacritic issue remains

You can see its properly formatted inside the workflow, before the CSV download occurs:

But when I open the CSV file weweb generates in excel, they are not respected:

Opening the file in Numbers or a text editor does show the diacritical marks. So this is somewhat an Excel-specific issue…but then the CSV file I generate entirely in supabase and later download using the ‘download file from URL’ action works fine in Excel, with exactly the same data.

So I think there may be some sort of CSV encoding issue with weweb? I’m not a CSV or text encoding expert; just speculating since the same data results in a ‘correct’ file in one place but not the other.

At this point its more of a curiosity/trying to understand what the correct way to do this is, as I’ll continue using the supabase hosted file variation since it yields a CSV file with intact diacritical marks when opened in Excel.