Having A Little Difficulty With Importing A CSV File

Below is the error message that I get from the failed import…

{
“code”: 0,
“file”: “/home/blaxstud/public_html/relco.cacregion.org/dmxConnectLib/modules/import.php”,
“line”: 42,
“message”: “array_combine(): Both parameters should have an equal number of elements”,
“trace”: “#0 [internal function]: exception_error_handler(2, ‘array_combine()…’, ‘/home/blaxstud/…’, 42, Array)\n#1 /home/blaxstud/public_html/relco.cacregion.org/dmxConnectLib/modules/import.php(42): array_combine(Array, Array)\n#2 /home/blaxstud/public_html/relco.cacregion.org/dmxConnectLib/lib/App.php(173): modules\import->csv(Object(stdClass), ‘csvImport_finan…’)\n#3 /home/blaxstud/public_html/relco.cacregion.org/dmxConnectLib/lib/App.php(137): lib\App->execSteps(Object(stdClass))\n#4 /home/blaxstud/public_html/relco.cacregion.org/dmxConnectLib/lib/App.php(107): lib\App->execSteps(Array)\n#5 /home/blaxstud/public_html/relco.cacregion.org/dmxConnectLib/lib/App.php(72): lib\App->exec(Object(stdClass))\n#6 /home/blaxstud/public_html/relco.cacregion.org/dmxConnect/api/Finance/IMPORT.php(335): lib\App->define(’{\n “settings”:…’)\n#7 {main}”
}

Perhaps there's a discrepancy between the number columns in the import file and the table you're importing into?

Quite possibly, but I just can’t find it. Ha! The CSV file is a download from a bank and the last column name ends with a #. Do you think that could be a problem?

How do you suppose I could remedy this? After several attempts, I’m not getting the error message that says, “Array to string conversion”.

I don’t know if the # symbol causes a problem - but it’s unusual in a column name, so it would certainly be worth checking (perhaps you already have). In case there’s something in the data which is causing a problem, I would try with just a few records, with no empty fields or unusual values.

What I would usually do next is try the import in Navicat, which gives detailed errors, eg:
[ERR] 1406 - Data too long for column 'some_column' at row 1
I find this and similar errors are often the problem with importing.

1 Like

I finally got it to work by removing all the column names that had spaces and removed the columns that had no data in the downloaded CSV file.

Do you think if I replace the space with a %20 or something like this would help?

1 Like

I think it’s better not to have spaces at all. Could you replace them with underscores for example? It shouldn’t be a problem if columns/rows have no data - unless they are defined as NOT NULL.

2 Likes

I’ve decided to just close up the spaces that the bank exports. I little extra work, but it works now. Thank you for your help.