# Import Lead Error

**URL:** <https://forum.mautic.org/t/import-lead-error/3402>\
**Category:** Product Support\
**Created:** [February 6, 2016, 10:35am UTC](https://forum.mautic.org/t/import-lead-error/3402 "2016-02-06T10:35:29Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![vishwajeet](https://avatars.discourse-cdn.com/v4/letter/v/34f0e0/32.png) [@vishwajeet](https://forum.mautic.org/u/vishwajeet)\
**Post date:** [February 6, 2016, 10:35am UTC](https://forum.mautic.org/t/import-lead-error/3402/1 "2016-02-06T10:35:29Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![vishwajeet](https://avatars.discourse-cdn.com/v4/letter/v/34f0e0/32.png) [@vishwajeet](https://forum.mautic.org/u/vishwajeet)\
**Post date:** [February 6, 2016, 10:35am UTC](https://forum.mautic.org/t/import-lead-error/3402/2 "2016-02-06T10:35:29Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![escopecz](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/escopecz/32/370_2.png) [@escopecz](https://forum.mautic.org/u/escopecz)\
**Post date:** [February 8, 2016, 12:21pm UTC](https://forum.mautic.org/t/import-lead-error/3402/3 "2016-02-08T12:21:32Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![vishwajeet](https://avatars.discourse-cdn.com/v4/letter/v/34f0e0/32.png) [@vishwajeet](https://forum.mautic.org/u/vishwajeet)\
**Post date:** [February 11, 2016, 7:30am UTC](https://forum.mautic.org/t/import-lead-error/3402/4 "2016-02-11T07:30:32Z")

</div>

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

Thanks,

---

<div class="post-metadata">

**Author:** ![escopecz](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/escopecz/32/370_2.png) [@escopecz](https://forum.mautic.org/u/escopecz)\
**Post date:** [February 11, 2016, 11:02am UTC](https://forum.mautic.org/t/import-lead-error/3402/5 "2016-02-11T11:02:40Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![vishwajeet](https://avatars.discourse-cdn.com/v4/letter/v/34f0e0/32.png) [@vishwajeet](https://forum.mautic.org/u/vishwajeet)\
**Post date:** [February 11, 2016, 11:14am UTC](https://forum.mautic.org/t/import-lead-error/3402/6 "2016-02-11T11:14:39Z")

</div>

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,

---

<div class="post-metadata">

**Author:** ![escopecz](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/escopecz/32/370_2.png) [@escopecz](https://forum.mautic.org/u/escopecz)\
**Post date:** [February 11, 2016, 11:28am UTC](https://forum.mautic.org/t/import-lead-error/3402/7 "2016-02-11T11:28:04Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![vishwajeet](https://avatars.discourse-cdn.com/v4/letter/v/34f0e0/32.png) [@vishwajeet](https://forum.mautic.org/u/vishwajeet)\
**Post date:** [February 11, 2016, 11:50am UTC](https://forum.mautic.org/t/import-lead-error/3402/8 "2016-02-11T11:50:15Z")

</div>

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,

---

<div class="post-metadata">

**Author:** ![escopecz](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/escopecz/32/370_2.png) [@escopecz](https://forum.mautic.org/u/escopecz)\
**Post date:** [February 11, 2016, 11:59am UTC](https://forum.mautic.org/t/import-lead-error/3402/9 "2016-02-11T11:59:13Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![vishwajeet](https://avatars.discourse-cdn.com/v4/letter/v/34f0e0/32.png) [@vishwajeet](https://forum.mautic.org/u/vishwajeet)\
**Post date:** [February 11, 2016, 12:01pm UTC](https://forum.mautic.org/t/import-lead-error/3402/10 "2016-02-11T12:01:35Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![davetbo](https://avatars.discourse-cdn.com/v4/letter/d/7ab992/32.png) [@davetbo](https://forum.mautic.org/u/davetbo)\
**Post date:** [June 13, 2016, 3:26pm UTC](https://forum.mautic.org/t/import-lead-error/3402/11 "2016-06-13T15:26:50Z")

</div>

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](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

---

<div class="post-metadata">

**Author:** ![davetbo](https://avatars.discourse-cdn.com/v4/letter/d/7ab992/32.png) [@davetbo](https://forum.mautic.org/u/davetbo)\
**Post date:** [June 13, 2016, 7:31am UTC](https://forum.mautic.org/t/import-lead-error/3402/12 "2016-06-13T07:31:23Z")

</div>

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
