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?
Each post in the
posts
table has a fieldpost_content_filtered
. It can take the same value aspost_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.