views:

69

answers:

2

I have to create a histogram/dictionary of all words found in parsing an html file. This includes a dictionary of all words found, and a histogram of their frequency.

I cant think of how to do this with PHP/MySQL because there could be potentially 2000 words that would have to be INSERTED at once =/

Any ideas?

+3  A: 

Just insert multiple records at one time, but, if one has an error the entire insert will fail.

http://www.desilva.biz/mysql/insert.html

"INSERT INTO beautiful (name, age)
  VALUES
  ('Helen', 24),
  ('Katrina', 21),
  ('Samia', 22),
  ('Hui Ling', 25),
  ('Yumie', 29)";
James Black
I saw this solution too, but the problem is I think there is a maximum to how many inserts you can do at once. And my best guess is there could be as many as 2500 words in some cases. So I'm not sure if this solves the problem.
codeninja
So split it up into multiple large inserts, as you can just do each of them in a separate thread.
James Black
+1  A: 

If you have that many entries, create a text file and use the LOAD DATA INFILE command.

http://dev.mysql.com/doc/refman/5.1/en/load-data.html

eykanal