Простенький парсер БД. Нужна помощь

CO
На сайте с 07.10.2006
Offline
39
1169

Всем привет!

В общем нужна помощь в создании парсера на пхп. Есть дамп БД в .SQL, нужно его преобразить к формату email;hash (выдернуть мыло и хэш с каждой записи)

кусочек базы

DROP TABLE IF EXISTS `user`;

CREATE TABLE `user` (
`userid` int(10) unsigned NOT NULL AUTO_INCREMENT,
`usergroupid` smallint(5) unsigned NOT NULL DEFAULT '0',
`membergroupids` char(250) NOT NULL DEFAULT '',
`displaygroupid` smallint(5) unsigned NOT NULL DEFAULT '0',
`username` varchar(100) NOT NULL DEFAULT '',
`password` char(32) NOT NULL DEFAULT '',
`passworddate` date NOT NULL DEFAULT '0000-00-00',
`email` char(100) NOT NULL DEFAULT '',
`styleid` smallint(5) unsigned NOT NULL DEFAULT '0',
`parentemail` char(50) NOT NULL DEFAULT '',
`homepage` char(100) NOT NULL DEFAULT '',
`icq` char(20) NOT NULL DEFAULT '',
`aim` char(20) NOT NULL DEFAULT '',
`yahoo` char(32) NOT NULL DEFAULT '',
`msn` char(100) NOT NULL DEFAULT '',
`skype` char(32) NOT NULL DEFAULT '',
`showvbcode` smallint(5) unsigned NOT NULL DEFAULT '0',
`showbirthday` smallint(5) unsigned NOT NULL DEFAULT '2',
`usertitle` char(250) NOT NULL DEFAULT '',
`customtitle` smallint(6) NOT NULL DEFAULT '0',
`joindate` int(10) unsigned NOT NULL DEFAULT '0',
`daysprune` smallint(6) NOT NULL DEFAULT '0',
`lastvisit` int(10) unsigned NOT NULL DEFAULT '0',
`lastactivity` int(10) unsigned NOT NULL DEFAULT '0',
`lastpost` int(10) unsigned NOT NULL DEFAULT '0',
`lastpostid` int(10) unsigned NOT NULL DEFAULT '0',
`posts` int(10) unsigned NOT NULL DEFAULT '0',
`reputation` int(11) NOT NULL DEFAULT '10',
`reputationlevelid` int(10) unsigned NOT NULL DEFAULT '1',
`timezoneoffset` char(4) NOT NULL DEFAULT '',
`pmpopup` smallint(6) NOT NULL DEFAULT '0',
`avatarid` smallint(6) NOT NULL DEFAULT '0',
`avatarrevision` int(10) unsigned NOT NULL DEFAULT '0',
`profilepicrevision` int(10) unsigned NOT NULL DEFAULT '0',
`sigpicrevision` int(10) unsigned NOT NULL DEFAULT '0',
`options` int(10) unsigned NOT NULL DEFAULT '15',
`birthday` char(10) NOT NULL DEFAULT '',
`birthday_search` date NOT NULL DEFAULT '0000-00-00',
`maxposts` smallint(6) NOT NULL DEFAULT '-1',
`startofweek` smallint(6) NOT NULL DEFAULT '1',
`ipaddress` char(15) NOT NULL DEFAULT '',
`referrerid` int(10) unsigned NOT NULL DEFAULT '0',
`languageid` smallint(5) unsigned NOT NULL DEFAULT '0',
`emailstamp` int(10) unsigned NOT NULL DEFAULT '0',
`threadedmode` smallint(5) unsigned NOT NULL DEFAULT '0',
`autosubscribe` smallint(6) NOT NULL DEFAULT '-1',
`pmtotal` smallint(5) unsigned NOT NULL DEFAULT '0',
`pmunread` smallint(5) unsigned NOT NULL DEFAULT '0',
`salt` char(3) NOT NULL DEFAULT '',
`ipoints` int(10) unsigned NOT NULL DEFAULT '0',
`infractions` int(10) unsigned NOT NULL DEFAULT '0',
`warnings` int(10) unsigned NOT NULL DEFAULT '0',
`infractiongroupids` varchar(255) NOT NULL DEFAULT '',
`infractiongroupid` smallint(5) unsigned NOT NULL DEFAULT '0',
`adminoptions` int(10) unsigned NOT NULL DEFAULT '0',
`profilevisits` int(10) unsigned NOT NULL DEFAULT '0',
`friendcount` int(10) unsigned NOT NULL DEFAULT '0',
`friendreqcount` int(10) unsigned NOT NULL DEFAULT '0',
`vmunreadcount` int(10) unsigned NOT NULL DEFAULT '0',
`vmmoderatedcount` int(10) unsigned NOT NULL DEFAULT '0',
`socgroupinvitecount` int(10) unsigned NOT NULL DEFAULT '0',
`socgroupreqcount` int(10) unsigned NOT NULL DEFAULT '0',
`pcunreadcount` int(10) unsigned NOT NULL DEFAULT '0',
`pcmoderatedcount` int(10) unsigned NOT NULL DEFAULT '0',
`gmmoderatedcount` int(10) unsigned NOT NULL DEFAULT '0',
`importuserid` bigint(20) NOT NULL DEFAULT '0',
`xperience` bigint(20) DEFAULT '1',
`xperience_done` smallint(6) DEFAULT '0',
`xperience_level` smallint(6) DEFAULT '1',
`xperience_levelp` smallint(6) DEFAULT '1',
`xperience_next_level` bigint(20) DEFAULT '0',
`xperience_next_level_points` bigint(20) DEFAULT '1',
`xperience_ppd` float DEFAULT '0',
`xperience_awards` mediumtext,
`xperience_shopitems` mediumtext,
`xperience_achievements` mediumtext,
`xperience_lastupdate` int(10) DEFAULT '0',
`xperience_awardcount` smallint(6) DEFAULT '0',
`xperience_promotioncount` smallint(6) DEFAULT '0',
`xperience_achievementcount` smallint(6) DEFAULT '0',
PRIMARY KEY (`userid`),
KEY `usergroupid` (`usergroupid`),
KEY `username` (`username`),
KEY `birthday` (`birthday`,`showbirthday`),
KEY `birthday_search` (`birthday_search`),
KEY `referrerid` (`referrerid`),
KEY `importuser_index` (`importuserid`)
) ENGINE=InnoDB AUTO_INCREMENT=141620 /*!40101 DEFAULT CHARSET=latin1 */;
INSERT INTO `aforums`.`user` VALUES
('1', '2', '', '0', 'pinki', '575ef00acbcdec548ba5d6f5610efbea', '2009-04-01', 'pinki@interbrands.net', '0', '', '', '', '', '', '', '', '2', '2', '1st Gear', '0', '1217608380', '0', '1259794117', '1265310780', '1229974500', '0', '2', '10', '1', '0', '0', '0', '0', '0', '0', '11536471', '', '0000-00-00', '-1', '1', '', '0', '0', '0', '0', '-1', '6', '6', '`d*', '0', '0', '0', '', '0', '0', '1244', '0', '0', '0', '0', '0', '0', '2', '0', '0', '0', '0', '1', '0', '1', '0', '0', '0', '', '', '', '0', '0', '0', '0'),
('2', '8', '', '0', 'DeletedUser', 'cf96ed9164faa67ff436fc1c245fd632', '2008-08-01', 'guest@yoururl.com', '0', '', '', '', '', '', '', '', '0', '2', '', '0', '1217608610', '0', '1217608610', '1217608610', '0', '0', '0', '0', '0', '', '0', '0', '0', '0', '0', '2135', '', '0000-00-00', '0', '0', '127.0.0.1', '0', '0', '0', '0', '0', '0', '0', '^zI', '0', '0', '0', '', '0', '0', '1943', '0', '0', '0', '0', '0', '0', '0', '0', '0', '-2', '0', '1', '0', '1', '0', '0', '0', '', '', '', '0', '0', '0', '0'),
('3', '11', '', '0', 'aforums', 'd04a01ba429eab82d282bab6d9e84aa1', '2008-08-01', 'test@afor.org', '0', '', '', '', '', '', '', '', '0', '2', '', '0', '1038288300', '0', '1109401740', '1109401740', '0', '0', '31', '0', '0', '', '0', '0', '0', '0', '0', '2135', '', '0000-00-00', '0', '0', '66.92.108.245', '0', '0', '0', '0', '0', '0', '0', 'U 7', '0', '0', '0', '', '0', '0', '329', '0', '0', '0', '0', '0', '0', '0', '0', '0', '1', '0', '1', '0', '1', '0', '0', '0', '', '', '', '0', '0', '0', '0'),

скажем, если отпарсить этот пример, то на выходе должно получится:

pinki@interbrands.net;575ef00acbcdec548ba5d6f5610efbea
guest@yoururl.com;cf96ed9164faa67ff436fc1c245fd632
test@afor.org;d04a01ba429eab82d282bab6d9e84aa1

по возможности, чтобы результат записывало в файл

заранее благодарен!

palladin_jedi
На сайте с 13.07.2010
Offline
71
#1

Убери верхушку до

chaOz:
INSERT*INTO*`aforums`.`user`*VALUES*

В каждой строке обрезай скобки, строку переводи в массив через разделитель запятую. 5 и 7 элементы массива бери в строку, строку дописывай в нужный файл.

Сайт о web-разработке и прочем (http://seazo.net)||Продвижение статьями под Google (http://short.seazo.net/ght4zf) Бесплатные консультации рефералам Sape (http://www.sape.ru/r.SWfwWOblBo.php) PHP и JS скрипты на заказ, создание сайтов с нуля и на CMS.
CO
На сайте с 07.10.2006
Offline
39
#2

спасибо, неактуально

DV
На сайте с 01.05.2010
Offline
644
#3

Какой там парсер...

cat, grep, awk

VDS хостинг ( http://clck.ru/0u97l ) Нет нерешаемых задач ( https://searchengines.guru/ru/forum/806725 ) | Перенос сайтов на Drupal 7 с любых CMS. ( https://searchengines.guru/ru/forum/531842/page6#comment_10504844 )
pssoft
На сайте с 12.04.2010
Offline
37
#4

Я хоть и кодер но делаю проще. Меняю скобки на символы табуляции и копирую все в excell там оно по полях разбивает )))

Интернет магазин активированных по смс аккаунтов (http://www.accs4sale.ru/) Вконтакте / Одноклассники / Loveplanet / Mamba / Gmail / Yandex и пр.

Авторизуйтесь или зарегистрируйтесь, чтобы оставить комментарий