Import Just Email

Hi Guys,

I have a txt file which contains data like the below:

Delete,Email,Test,Status
-1,xxxx@cityacademy.bristol.sch.uk,SMTP,Could not verify recipient
-1,xxxx@brookes.co.uk,SMTP,No mail exchange for domain
-1,xxxx@hotmail.co.uk,SMTP,Recipient rejected
-1,xxxx@hotmail.co.uk,SMTP,Recipient rejected

I want to import just the Email values to my table which just has 1 field called Email. How do i go about doing this?

Any help would be great.

Thanks

  • read the text file
  • loop through the lines, get the email from each line and store it in an array
  • create the insert query
  • execute the insert query

If you need help with some specific part, don’t hesitate to ask

Hi Guido,

Thanks for your comment, I really dont have a clue how to do all that, I’m only a beginner with MySQL unfortunately so I dont know how to do what you have said :frowning:

Thanks

You want to do it all in MySQL? PHPMyAdmin lets you import comma separated value files. But I have no idea if you can specify to import only one value.

Maybe you could create a temporary table to load the CSV file, and then copy the emails to the email table?

Yea think I’ll have to create a new table and do it the way you said :slight_smile: Thanks

i would create a table with all the columns, then do a LOAD DATA INFILE using the text file, then create my desired table with just the email column, and do a INSERT INTO SELECT, then drop the uploaded table

Edit: um, yeah… what guido said

:slight_smile: