2

I have a custom post type which represents a 'race' and there are meta fields for 'distance' (5km,10Mile) and 'type' (track,road,crosscountry). We get the race results as a csv file which contains the positions and times etc of the runners, each runner is linked to a wordpress user. The intention is to process the csv data and insert it into a custom database table. The results are then displayed via a WP_Table_List. My question is how i should best save the csv data so that it can be processed, the two options as i see are

1 - Save the csv data into the post content section. I'd then add a custom action 'Process Content CSV' which reads the content and processes the rows inserting into the database.

2 - As a custom meta field 'csv_results' which is setup to accept a file_upload. Once the file is uploaded and the post save, the content of the file is then processes and inserted into the db.

With option one i'd be worried that wordpress will filter out my delimiter char and option 2 seems too complicated. Which approach and what issues would you watch out for?

1 Answer 1

0

Each post in the posts table has a field post_content_filtered. It can take the same value as post_content (longtext) and it is available without a meta query.

On the other hand … you could create a custom table and import the CSV as regular table content. In MySQL that’s easy with LOAD DATA INFILE. And then you could create a nice interface to edit the data, you can search specific fields … and export everything as CSV.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.