0

I am having some problems with mysql importing text into a database. My .txt file looks like this:

a.txt

Pattern: 1

Address: 18PhQkzkzP6QUmWuiddhJ2YrGKZKRmV3j

Privkey: 5JRpLiEcq57ijgfVGmmE19V1F29zPkwWjTQinJJJpfYtqA3ZcbY

Pattern: 1

Address: 18zvgu7k8WxAnwgghdudhdzYRCo7aEVPBUU

Privkey: 5JmAp8QgujxDhwJHwgkW9FkiuWEkSDwZL73Xu8ihAY2fy3Kjmn3  

etc....

I want to import this txt. file into a database called bitcoin with the table a from a.txt. All lines from the "Pattern: 1" should disappear and the table "a" should only have two columns:" address and privkey" which address as the prim. key.

mysql> LOAD DATA LOCAL INFILE "/home/weber/Desktop/a.txt" INTO TABLE a

-> FIELDS TERMINATED BY ':'

-> LINES STARTING BY 'Address' 

-> IGNORE 1 LINES;

Seems not working very well, anyone with some mysql knowledge could give me a hint, thanks.

  • possible duplicate question [here](http://stackoverflow.com/questions/14313708/import-text-file-into-mysql-workbench). Your text file is also not in the right format. – KarelG Aug 10 '13 at 12:04

1 Answers1

0

You seem to think that the file can use more than one line in the text file for a row. You need to use one line per row.

Try:

Pattern:Address:Privkey
1:18PhQkzkzP6QUmWuiddhJ2YrGKZKRmV3j:5JRpLiEcq57ijgfVGmmE19V1F29zPkwWjTQinJJJpfYtqA3ZcbY
1:18zvgu7k8WxAnwgghdudhdzYRCo7aEVPBUU:5JmAp8QgujxDhwJHwgkW9FkiuWEkSDwZL73Xu8ihAY2fy3Kjmn3  

And do not use the "LINES STARTING BY 'Address'" in the command. Read up at http://dev.mysql.com/doc/refman/5.1/en/load-data.html or something similar for info on using that properly.

Ray Kiddy
  • 3,521
  • 3
  • 25
  • 32