Title: Mapping rules import from CSV
Last modified: November 8, 2017

---

# Mapping rules import from CSV

 *  Resolved [jaak69](https://wordpress.org/support/users/jaak69/)
 * (@jaak69)
 * [8 years, 7 months ago](https://wordpress.org/support/topic/mapping-rules-import-from-csv/)
 * Hello,
    I didn’t find from documentation is it possible to import mapping rules
   from csv file. The main CSV import file has field “countryID” which is number
   and I have another CSV file there “countryID” mapped with actual country name(
   132 records). I can manually insert them as mapping rules, but is it possible
   to automate that and import all from csv file.
 * Jaak
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fmapping-rules-import-from-csv%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

Viewing 4 replies - 1 through 4 (of 4 total)

 *  [Duffdaddy](https://wordpress.org/support/users/duffdaddy/)
 * (@duffdaddy)
 * [8 years, 7 months ago](https://wordpress.org/support/topic/mapping-rules-import-from-csv/#post-9662014)
 * Let me know if you find a solution. Have the same issue.
 *  Plugin Author [WP All Import](https://wordpress.org/support/users/wpallimport/)
 * (@wpallimport)
 * [8 years, 7 months ago](https://wordpress.org/support/topic/mapping-rules-import-from-csv/#post-9673101)
 * Hi [@jaak69](https://wordpress.org/support/users/jaak69/)
 * It sounds like you could use a [PHP function](http://www.wpallimport.com/documentation/developers/execute-php/)
   or [our API](http://www.wpallimport.com/documentation/developers/action-reference/)
   to translate the values.
 * Can you provide more details on where you’re importing the “countryID” data? 
   Is it a custom field, a taxonomy, or something else? If you have some data examples
   that would be helpful as well.
 *  Thread Starter [jaak69](https://wordpress.org/support/users/jaak69/)
 * (@jaak69)
 * [8 years, 6 months ago](https://wordpress.org/support/topic/mapping-rules-import-from-csv/#post-9684634)
 * Hello,
    This is a custom field: It looks in import csv: country_id 0 53 0 17 
   0 0
 * And the mapping csv:
    country_id 1 Eesti EE 3 Venemaa RU 4 Soome FI 11 Leedu 
   LT 12 Läti LV 13 Poola PL 14 Hispaania ES 15 Itaalia IT 16 Türgi TR 17 Hiina 
   CN 18 Andorra AD 19 Araabia Ühendemiraadid AE 20 Albaania AL 21 Armeenia AM ….
   etc.
 *  Plugin Author [WP All Import](https://wordpress.org/support/users/wpallimport/)
 * (@wpallimport)
 * [8 years, 6 months ago](https://wordpress.org/support/topic/mapping-rules-import-from-csv/#post-9701947)
 * Hi [@jaak69](https://wordpress.org/support/users/jaak69/)
 * Thank you for the example. Unfortunately, there are currently no built-in options
   to import mapping rules like this, but you could do it with your own custom solution.
 * You should convert the mapping CSV to a PHP array (see [str_getcsv](http://php.net/manual/en/function.str-getcsv.php)),
   then write a PHP function for the mapping rules. Example:
 *     ```
       // Map function
       function my_map_field( $data ) {
           // Replace this array with the data from your CSV file
           $map = array(
                   'Translate This' => 'To This New Value',
                   'And this' => 'To this',
                   'Add as many' => 'Rules',
                   'As you need' => 'In this array',
               );
   
           return isset( $map[ $data ] ) ? $map[ $data ] : $data;
       }
       ```
   
 * You can use that function in the import template as described here: [http://www.wpallimport.com/documentation/developers/execute-php/](http://www.wpallimport.com/documentation/developers/execute-php/).

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Mapping rules import from CSV’ is closed to new replies.

 * ![](https://ps.w.org/wp-all-import/assets/icon-256x256.png?rev=2570179)
 * [WP All Import – Drag & Drop Import for CSV, XML, Excel & Google Sheets](https://wordpress.org/plugins/wp-all-import/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wp-all-import/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wp-all-import/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-all-import/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-all-import/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-all-import/reviews/)

 * 4 replies
 * 3 participants
 * Last reply from: [WP All Import](https://wordpress.org/support/users/wpallimport/)
 * Last activity: [8 years, 6 months ago](https://wordpress.org/support/topic/mapping-rules-import-from-csv/#post-9701947)
 * Status: resolved