Title: Programmatically import new table
Last modified: February 6, 2020

---

# Programmatically import new table

 *  Resolved [dostrog](https://wordpress.org/support/users/dostrog/)
 * (@dostrog)
 * [6 years, 3 months ago](https://wordpress.org/support/topic/programmatically-import-new-table/)
 * Hi Tobias!
 * Thanks for your great job!
 * I have on small question. Is there any way to direct import new (csv) table?
 * I developed plugin where get data from other server by API and store them in 
   CSV file. Then I would like to put it to site’s DB for future operating by TablePress(
   set AutoImport options, etc).
 * Do I need to make 2-dimensional json data in #_posts table (make changes in #
   _options etc) or is there any function/methods in TablePress controllers/models
   to make this?
 * I can make HTTP request like from TablePress Import tabs with posts params, but
   it is not right way, I think.

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

 *  Plugin Author [Tobias Bäthge](https://wordpress.org/support/users/tobiasbg/)
 * (@tobiasbg)
 * [6 years, 3 months ago](https://wordpress.org/support/topic/programmatically-import-new-table/#post-12409456)
 * Hi,
 * thanks for your post, and sorry for the trouble.
 * If you already have the data in your plugin, you shouldn’t even need the CSV 
   file (unless you want the CSV file for something else of course).
    However, instead
   of directly manipulating the table data in the database, which is not very fail-
   safe, I would recommend to simply do it in the same way as TablePress, when it
   saves a modified table after a user edits it. So, basically, you could extract
   the relevant code from the controller, see [https://github.com/TobiasBg/TablePress/blob/master/controllers/controller-admin_ajax.php#L68](https://github.com/TobiasBg/TablePress/blob/master/controllers/controller-admin_ajax.php#L68)
 * Alternatively, you could trigger a manual import of CSV data in the same way 
   as e.g. the TablePress Extension from [https://tablepress.org/extensions/table-auto-import/](https://tablepress.org/extensions/table-auto-import/)
   does it. Just check its code.
 * Regards,
    Tobias
 *  Thread Starter [dostrog](https://wordpress.org/support/users/dostrog/)
 * (@dostrog)
 * [6 years, 2 months ago](https://wordpress.org/support/topic/programmatically-import-new-table/#post-12445166)
 * Thanks for your advice, Tobias! In the end, I successfully solved my problem.
 * I copied a few snippets from your code (private methods), but tried to call the
   TabletPress classes public methods directly. I hope that I did not violate the
   license.
 * Thank you for you great job and well documented code!
 *  Plugin Author [Tobias Bäthge](https://wordpress.org/support/users/tobiasbg/)
 * (@tobiasbg)
 * [6 years, 2 months ago](https://wordpress.org/support/topic/programmatically-import-new-table/#post-12445263)
 * Hi,
 * great! Good to hear that you could make it work!
 * And no worries about the license, this is all ok 🙂
 * Regards,
    Tobias

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

The topic ‘Programmatically import new table’ is closed to new replies.

 * ![](https://ps.w.org/tablepress/assets/icon.svg?rev=3192944)
 * [TablePress - Tables in WordPress made easy](https://wordpress.org/plugins/tablepress/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/tablepress/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/tablepress/)
 * [Active Topics](https://wordpress.org/support/plugin/tablepress/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/tablepress/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/tablepress/reviews/)

## Tags

 * [direct access](https://wordpress.org/support/topic-tag/direct-access/)
 * [Import](https://wordpress.org/support/topic-tag/import/)

 * 3 replies
 * 2 participants
 * Last reply from: [Tobias Bäthge](https://wordpress.org/support/users/tobiasbg/)
 * Last activity: [6 years, 2 months ago](https://wordpress.org/support/topic/programmatically-import-new-table/#post-12445263)
 * Status: resolved