Importing Contacts from a CSV file

Hi all,

Iā€™m attempting to import around 2900 contacts from a CSV file. Iā€™ve been careful to ensure the fields have been correctly defined.

During the import process the message is displayed:

Importing records 101 to 200 of 2908 ā€¦

The import progresses to the end but then bombs out. When I go to check the number of contacts, the total is only around 800 records.

Looking at the logs in the file ā€¦ I get the following error message:

[Mon Sep 04 11:34:11.476436 2023] [php:error] [pid 11207] [client 192.168.100.163:50975] PHP Fatal error: Uncaught TypeError: count(): Argument #1 ($value) must be of type Countable|array, bool given in /var/www/html/SuiteCRM-7.13.4/modules/Import/views/ImportListView.php:130\nStack trace:\n#0 /var/www/html/SuiteCRM-7.13.4/modules/Import/views/view.last.php(188): ImportListView->display()\n#1 /var/www/html/SuiteCRM-7.13.4/modules/Import/views/view.last.php(140): ImportViewLast->getListViewTableFromFile()\n#2 /var/www/html/SuiteCRM-7.13.4/include/MVC/View/SugarView.php(210): ImportViewLast->display()\n#3 /var/www/html/SuiteCRM-7.13.4/include/MVC/Controller/SugarController.php(432): SugarView->process()\n#4 /var/www/html/SuiteCRM-7.13.4/include/MVC/Controller/SugarController.php(363): SugarController->processView()\n#5 /var/www/html/SuiteCRM-7.13.4/include/MVC/SugarApplication.php(101): SugarController->execute()\n#6 /var/www/html/SuiteCRM-7.13.4/index.php(52): SugarApplication->execute()\n#7 {main}\n thrown in /var/www/html/SuiteCRM-7.13.4/modules/Import/views/ImportListView.php on line 130, referer: http://suitecrm.aosgrp.net/index.php

It is possible that there is an input record that is causing the import to fail ? There must be a way to find out which record is causing the process to fail.

It really helps if you include your SuiteCRM and PHP versions in every new thread, itā€™s the ā€œbasic coordinatesā€ for troubleshooting anything.

From the looks of that error, Iā€™d start by checking PHP version issues. If that doesnā€™t help and you really need to go and find a guilty record, use the bisection method.

This is a typical php 8+ incompatibility
Either change php version to php7.4
Or
Go to this file check is_countable() before this line

Thanks for the tip(s).

  • The version of SuiteCRM is: 7.13.4
  • PHP version: 8.1.2 (PHP 8.1.2-1ubuntu2.14)

Iā€™m looking at the compatibility matrix once more (Compatibility Matrix :: SuiteCRM Documentation) I can see that the version I have is slightly off the supported version of PHP

  • SuiteCRM 7.13.4 (supported version of PHP is 7.4, 8.0. I have version 8.1.2

SuiteCRM 7.14 was just released. Perhaps I should try the installation again with this version which will match the version of PHP I currently have installed ?

With respect to the contacts, it looks like I had a filter on. After clearing the filter and reverting to a previous state (prior to the first import attempt) I managed to import 2217 contacts out of a total of 2908. The ā€˜bisectionā€™ method looks like a good technique. Pity the system doesnā€™t provide some output of where the error occurs.

Thanks for the tip. Going back to an older (major) version of PHP doesnā€™t seem like a good idea taking into account it is no longer supported.

It looks like the version of SuiteCRM (7.13.4) works with PHP 7.4 and 8.0 but not 8.1 (which is what I have installed).

I might go back and try SuiteCRM 7.14 which was only just released.

PS: Which file are you referring to re checking the variable is_countable() ?

Hi,

@jg007 You have to go with PHP 8.0 or 7.4. No other way. Otherwise you will see errors and unexpected behavior everywhere.

If you are going with fresh installation, then the good approach is to go with LTS/ESR version of SuiteCRM. Going with the latest version is never recommended for any production requirements.

And last thing, for import, check the imported records, let say in your case you are successfully importing 800 records, then check record no 801 and 802 in the CSV file, you can see the problem there. By the way

I think changing the PHP version will make your import process successful skipping these errors.

Thanks

Thanks for the tip.

I ended up going for SuiteCRM 7.14 which seems to have reduced the number of errors Iā€™m getting and works with PHP 8.1 according to the compatibility matrix.

This is not a production environment as Iā€™m currently setting up an evaluation for a number of users. No doubt there is an upgrade process that I can follow in the future, correct ?

yes yes you can go with updated version when you want. So your problem resolved? If not then you can instantly join me over skype and i can help you.
Thanks

in the file:
modules/Import/views/ImportListView.php line: 130
change:

        $this->ss->assign('colCount', count($this->headerColumns));

to

        $this->ss->assign('colCount', is_countable($this->headerColumns)?count($this->headerColumns):0);

As mentioned previously I have already moved onto SuiteCRM 7.14.0.

For this version of SuiteCRM, the file ImportListView.php still contains the entry (on line 131)

$this->ss->assign(ā€˜colCountā€™, count($this->headerColumns));

Do you recommend I still change it to the value youā€™ve suggested ?

The original errors I reported have disappeared. I occasionally get the following messages but itā€™s infrequent:

[Tue Sep 05 13:52:05.878450 2023] [php:notice] [pid 1538] [client 192.168.100.163:59342] PHP Notice:  session_start(): ps_files_cleanup_dir: opendir(/var/lib/php/sessions) failed: Permission denied (13) in /var/www/html/SuiteCRM-7.14.0/include/MVC/SugarApplication.php on line 609, referer: http://suitecrm.aosgrp.net/index.php?action=index&module=Contacts&searchFormTab=basic_search&query=true&clear_query=true
[Tue Sep 05 14:04:10.705350 2023] [php:notice] [pid 1285] [client 192.168.100.163:60353] PHP Notice:  session_start(): ps_files_cleanup_dir: opendir(/var/lib/php/sessions) failed: Permission denied (13) in /var/www/html/SuiteCRM-7.14.0/include/MVC/SugarApplication.php on line 609, referer: http://suitecrm.aosgrp.net/index.php?module=Administration&action=index
[Tue Sep 05 14:04:17.302591 2023] [php:notice] [pid 1287] [client 192.168.100.163:60354] PHP Notice:  session_start(): ps_files_cleanup_dir: opendir(/var/lib/php/sessions) failed: Permission denied (13) in /var/www/html/SuiteCRM-7.14.0/include/MVC/SugarApplication.php on line 609, referer: http://suitecrm.aosgrp.net/index.php?module=Administration&action=index
[Tue Sep 05 14:51:55.837537 2023] [php:notice] [pid 2814] [client 192.168.100.163:51011] PHP Notice:  session_start(): ps_files_cleanup_dir: opendir(/var/lib/php/sessions) failed: Permission denied (13) in /var/www/html/SuiteCRM-7.14.0/include/MVC/SugarApplication.php on line 609, referer: http://suitecrm.aosgrp.net/index.php?action=ajaxui
[Tue Sep 05 15:20:27.179765 2023] [php:notice] [pid 2799] [client 192.168.100.163:54037] PHP Notice:  session_start(): ps_files_cleanup_dir: opendir(/var/lib/php/sessions) failed: Permission denied (13) in /var/www/html/SuiteCRM-7.14.0/include/MVC/SugarApplication.php on line 609, referer: http://suitecrm.aosgrp.net/index.php?module=Home&action=index

I attempted a new CSV file import with no errors have been reported in the file /var/log/apache2/suitecrm_error.log

By the way Iā€™m impressed with the responsiveness of this comminity forum. Compared to other forums I have to wait weeks or not get any assistance at all.

I appreciate the help from the community so far. Thank you. :+1:

Did you move 7.14 to production? Is it working perfectly for you?

Yes, moving to 7.14.0 seems to have been a significant improvement (so far).

I also found my import issues where not related to SuiteCRM but the format of the original data itself. After cleaning up the data I was able to import about 99% of the data

1 Like