Mautic Community Forums

Import Lead Error

Hi,

I tried many times to import leads in csv format but every time it shows unable to read imported csv file. I tried to search forum for possible solution but no luck. Mautic installation is running fine without any error but can’t understand problem with importing leads.

Is there any fix for it?



Thanks

Hi,
I tried many times to import leads in csv format but every time it shows unable to read imported csv file. I tried to search forum for possible solution but no luck. Mautic installation is running fine without any error but can’t understand problem with importing leads.
Is there any fix for it?

Thanks

Could you post a link to your CSV or at least part of it so we could see the data structure?

Hi,
Sorry for late reply. Here is link for CSV file:
https://www.dropbox.com/s/hodwo5peyyttks4/Lead%20list%20construction%20company1.csv?dl=0

Thanks,

I was able to upload the file without any problem. Does it fail on file upload or lead import? My guess is that you have some file permission issue on your server which is preventing Mautic to work with the file.

Hi,
I think it is failing when uploading file. It shows message “Unable to read the imported csv file.”
What file permissions I need to modify to work mautic with file?

Thanks,

All Mautic folders and files should be writable by PHP (Mautic). Contact your web hosting provider and ask him to check the permissions for you.

Mautic root folder have 755 permission, app folder have 777 permission, remaining folders have 755 permission and all files have 644 permissions. Is that ok or I need to change any permissions?

Thanks,

Seems OK. The app folder should have 644 as well, but it might be a linux user (owning the files) problem. That’s why it’s better to consult it with someone who has knowledge about your particular server.

Ok, thanks for your help. At least now I know that it is server problem.

Upon further debugging, when the config data comes out of :
$config = $form->getData();
it looks like this:
[13-Jun-2016 16:23:11 UTC] Config: Array
(
[file] => SymfonyComponentHttpFoundationFileUploadedFile Object
(
[test:SymfonyComponentHttpFoundationFileUploadedFile:private] =>
[originalName:SymfonyComponentHttpFoundationFileUploadedFile:private] => subscriber_import.csv
[mimeType:SymfonyComponentHttpFoundationFileUploadedFile:private] => text/csv
[size:SymfonyComponentHttpFoundationFileUploadedFile:private] => 5001
[error:SymfonyComponentHttpFoundationFileUploadedFile:private] => 0
[pathName:SplFileInfo:private] => /tmp/php2drQAg
[fileName:SplFileInfo:private] => php2drQAg
)

[delimiter] => ,
[enclosure] => "
[escape] => \
[batchlimit] => 100

Per this page (http://php.net/manual/en/splfileobject.fgetcsv.php) it says that escape and enclosure can only be one character, so fgetcsv is choking. I can manually override it by setting this before the fgetcsv call:
$config[‘escape’] = “”;
$config[‘enclosure’] = ‘"’;
so I know that’s the problem that’s stopping it at this point. It’s definitely a bug somewhere. Please advise.

Best,
Dave

I’m having a problem with this, too. I did chmod -R g+w for the marketing folder, and the apache user is in the group, so I know it can write to it. Also, I’m getting this in the mautic logs:
mautic.WARNING: PHP Warning: SplFileObject::fgetcsv(): escape must be a character - in file /var/www/html/marketing/app/bundles/LeadBundle/Controller/LeadController.php - at line 1417 [] []

It’s therefore looking like not a permissions problem, but a code problem. Also, every time it comes back with the “Unable to read the imported csv file.” on the front end, it puts another slash in front of the escape and enclosure characters. I started with " for the enclosure and for the escape. Then after the first submission it looks prepends slashes so they look like " and , then " and \. You get the picture. I’ve tried it repeatedly and now they’re up to \" and \\. I think there’s a bug. This is on Mautic 1.4.1.

Best,
Dave