Quick CSV import with visual mapping

development, php, php classes Add comments

Several years ago I created PHP class Quick_CSV_Import to import CSV files to a database table very quickly (LOAD DATA INFILE statement). I found that the class became quite popular in India due to feedback received :]

Now I want to share a little application on the basis of that class.

Quick CSV Import with Mapping” is a PHP example application that imports CSV file to a database table with visual mapping of CSV columns to table columns.

CSV Mapping Master - click to download

Of course, you can get a copy of the application source – just go to the SVN repository.

Don’t forget to send me your feedback and donations ;]

P.S. If you are having problems with going to step 2 while using the app, try the following:

  1. Open Quick_CSV_import.class and find “LOAD DATA INFILE
  2. change it to “LOAD DATA LOCAL INFILE

It’s connected with permissions at your Linux server. Thanks to Noel for the solution.

156 Responses to “Quick CSV import with visual mapping”

  1. james Says:

    Good day

    i have this error when i get to step2. Need your help

    Warning: fopen(C:\xampp\htdocs\quickimport\trunk\temp\csv\csv730.tmp): failed to open stream: Permission denied in C:\xampp\htdocs\quickimport\trunk\classes\functions.php

    CSV::convert_line returned 0 rows which is not good

  2. Al Says:

    I’m trying to use this code with an HTTP POST file that is served up by a 3rd party integration provider, so, I’m not working with a saved file, thus the file path is essentially ‘https:\\www.teapplix.com\h\aquadesign\ea\admin.php?User=myusername&Passwd=mypassword&Action=Report&Subaction=OrderRun’

    The file is reading just fine…your class is able to read the file, read the headers and create a new table. However, when the LOAD DATA LOCAL INFILE query tries to run I’m receiving the following message:

    Errors: File ‘https:\\www.teapplix.com\h\aquadesign\ea\admin.php?User=al@XXXX.com&Passwd=XXXXXX&Action=Report&Subaction=OrderRun’ not found (Errcode: 22)

    Any thoughts?

  3. stefko Says:


    worked perfectly, no longer getting both of these errors:

    Warning: trim() expects parameter 1 to be string, resource given in /var/www/html/php/test/csv/classes/DB.class.php on line 290
    Database user test1 must have SELECT permission

    and also the issue with:

    Cannot retrieve headers columns of the CSV file

  4. Bruce Says:

    I get a bunch of errors. I am new to PHP, so please forgive me. I have this configuration: PHP Version 5.6.0, Microsoft-IIS/7.5 on Windows Server 2008 R2 Standard Edition Service Pack 1, and MySQL Server 5.6.19-log

    These are the errors I get:

    Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in C:\inetpub\ftproot\casaozeta\movies\test.php on line 5

    Notice: Undefined variable: HTTP_POST_FILES in C:\inetpub\ftproot\casaozeta\movies\test.php on line 18

    Warning: fopen(): Filename cannot be empty in C:\inetpub\ftproot\casaozeta\movies\Quick_CSV_import.php on line 65

    Warning: fopen(): Filename cannot be empty in C:\inetpub\ftproot\casaozeta\movies\Quick_CSV_import.php on line 65
    Quick CSV import

    Errors: file cannot be opened: [empty]

  5. mujtaba Says:

    I am having an error like dave #35 can’t find file please suggest any solution.


  6. Rahul Says:

    I need To Know Is There Any Way To Set value for Field Name by default
    for an example i have a field in my table that is “list_id”
    i want to do that on index page there should be a text field where we can input a value and then after loading csv file of 100 records then it should also insert this record with list_id value which we have earlier set on index page so in this way for that 100 records my field => list_id value = should be the value we written on index page.
    I hope You Understand..If Any one can help me this

WP Theme & Icons by N.Design Studio
Entries RSS Comments RSS Log in