I've been tasked with a project where the user needs to access the front end admin page that I've created and upload a CSV (1-3 daily). This Information needs to go into a database and be split into multiple tables (which I've also created). I've come up with some PHP code that can split a CSV into multiple tables upon import, but I'm looking to see if there is a better way to do this in Wordpress, maybe even via plugin.

Currently, working on my local server, I made a test HTML page with an upload section. In PHP, I have this handled to read the CSV and put the 203 fields into an array, splitting these by column names into 7 different tables. It's a lot of code but I think it works. For this to work on the wordpress site, I'll have to add the database and tables and then use a plugin to insert PHP code.

The only other factor is after an upload, I'll need the option to display the cvs data in another screen on a table. The main thing here is reading the CSV and putting the data in different DB tables in WP. Does anyone know of a better way to do this?

  • wpallimport.com is a pretty robust plugin. If you go with a custom solution, make sure to only enable uploads in wp-admin, so that only authenticated users with the right access level will be able to upload the files. It's still a security risk allowing folks to import CSVs so the more you can rely on already-coded solutions such as WPAllImport, the safer it potentially will be. You might also want to consider whether a more native solution fits here - for example, would the data be compatible as a custom post type with custom postmeta? – WebElaine Mar 16 '17 at 16:33
  • I like the look of that plugin but I'm still investigating it. I'm not too sure on your last question there, but the web page already exists, I just have to implement the database function. Basically, The CSV exports in the same fashion with the same column order every time. It has around 203 columns/fields, so my 7 tables house 203 fields for those to be stored in. I just have to find a way to upload the CSV and import it/split it to multiple tables and then on the report page I have to display the data in a form or table – H.Norman Mar 16 '17 at 16:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.