Errors importing CSV files why a 500 error and no reason why it should be - WHY?

I am trying to import a CSV file and I am constantly getting a 500 error when it tries to import.

I have done this before and it works fine but now I am getting this error and for the life of me I can not see why!

I have checked the CSV file and all headers are correct and its one I have used elsewhere with success.

The file uploads to the correct folder.

I have designated the correct path.

What on earth would be causing this to occur???

{status: "500", message: "parseCSV: email is missing in undefined",…}
message: "parseCSV: email is missing in undefined"
stack: "Error: parseCSV: email is missing in undefined\n    at /opt/node_app/lib/modules/import.js:22:23\n    at Array.forEach (<anonymous>)\n    at parseCSV (/opt/node_app/lib/modules/import.js:20:24)\n    at App.csv (/opt/node_app/lib/modules/import.js:117:16)\n    at async App._exec (/opt/node_app/lib/core/app.js:435:30)\n    at async App._exec (/opt/node_app/lib/core/app.js:406:17)\n    at async App.exec (/opt/node_app/lib/core/app.js:375:9)\n    at async App.define (/opt/node_app/lib/core/app.js:365:9)"
status: "500"

The request:

1 Like

You have chosen that your csv contains headers, so the first line of it should be with the header names exactly as you named them.

Seems e-mail is then missing or differently named.

Thanks @George but that is just it its not.

See the request:

3a

It seems not matter what you name the first column and specify in the headers the same error occurs at the first header. Something else is going on here. As you can see the file and the headers are correct?

How do you create this file? Maybe there’s a BOM there which is causing this. I think the script should detect the BOM and ignore it if present, @patrick?

Using excel in Mac and saving as CSV Utf8

Using version 3.9.9

check the uploaded path - of the real file saved on the server. Maybe it is just empty or path is wrong for the import.

Nope all correct

As specified here with file having read write permissions.

Have you checked in Chrome Dev Tools (Network tab) that the file is being sent with the form?

‘in undefined’ suggests the file isn’t there or not accessible

Yeah. If you look at above it uploads the file and adds the ext as specified. The path is selected as specified. There is no issue with file upload and the file is read write access.

Im not doing anything unusual with this file and nothing I haven’t done previously. But it is the first time I have done it with this version of Wappler.

This does look like a BOM issue.
I had a similar issue few years ago in core PHP I think.
The temporary solution I did was add a blank column, and ignore the first column. Because I did not know about BOM then.

@StevenM Try adding a blank column as the first column and see if the import works then.

1 Like

Try the following update, it should strip the BOM when it is present.

Unzip in lib/modules

import.zip (1.1 KB)

1 Like

Thanks @patrick this fixed it!

Cheers!

Fixed in Wappler 4 beta 8

This topic was automatically closed after 45 hours. New replies are no longer allowed.