I've got an excel file containing a list of records by firstname, lastname, email_address, transaction_id
I'd like to create a script that reads in the excel data (can be csv or whatever export is easiest to work with) and inserts each record as a user in my wordpress database with the role of "membe开发者_StackOverflowr".
You can explode each line on the delimter (like ,
) or you could use fopen
and fgetcsv
to parse line by line. Overall the general procedure is not difficult. for example:
$fileResource = fopen('/path/to/file.csv', 'r');
while(($data = fgetcsv($fileResource, ',')) !== false)
{
// $data is numeric indexed array
// do stuff with $data
}
精彩评论