2012-04-11 66 views
0

我有一个作为CSV导出的自定义数据库。我重新排列了列和数据以匹配Wordpress数据库的列,因此我可以导入数据。将CSV文件导入到包含html的phpmyadmin中

唯一的问题是自定义数据库中的一列包含HTML。这会阻止将数据作为CSV导入Wordpress。有什么办法可以解决这个问题吗?我真的需要保留HTML,因为我不想再次修改数百行。

需要一段时间才能将数据转换为首要操作的格式。

p.s如果我导入没有HTML列的数据,它将导入到Wordpress中。

下面是一个例子:

ID,post_author,post_date,post_date_gmt,post_content,post_title,post_excerpt,post_status,comment_status,ping_status,post_password,post_name,to_ping,pinged,post_modified,post_modified_gmt,post_content_filtered,post_parent,guid,menu_order,post_type,post_mime_type,comment_count 
5000,1,28/02/2012 15:00,28/02/2012 15:00,"<p>Marriott Royal Hotel, College Green, Bristol<br /> 
<br /> 
We are pleased to announce the launch of the <a rel=""nofollow"" target=""_blank"" href=""http://www.inets-sw.co.uk/default.aspx?page=495"">Microelectronics iNet</a> for the South West. This &pound;2.3 million ERDF funded project will facilitate innovation and growth across the microelectronics industry by working with businesses to transform exciting ideas into new products and services.</p> 
<p>Join us for the opportunity to learn more about the iNet and to hear leading technology entrepreneur Professor David May speaking on future trends and opportunities.</p> 
<p>Speaking alongside Professor May will be Rick Chapman, Director of the Microelectronics iNet and Nick Sturge, Director of the SETsquared Business Acceleration Centre in Bristol.</p> 
<p>Please register by Friday 26 November.</p> 
<p><a rel=""nofollow"" target=""_blank"" href=""http://www.inets-sw.co.uk/micro/events/december_200/ingenious_britain_in_action.aspx"">Further details</a> or <a target=""_blank"" rel=""nofollow"" href=""https://www.formstack.com/forms/inets-launch"">book now</a></p> 
<p>About the iNets<br /> 
The Microelectronics iNet is a consortium of universities, commercial organisations and industry networks. The project is led by the University of the West of England, and includes the University of Bristol, STMicroelectronics, the National Microelectronics Institute and the Electronics, Sensors and Photonics KTN.<br /> 
<br /> 
Agenda<br /> 
16:00 Arrival<br /> 
16:30 Welcome &amp; Introduction<br /> 
16:45 Professor David May<br /> 
17:30 Rick Chapman<br /> 
17:50 Nick Sturge<br /> 
18:30 Drinks and canap&eacute;s</p> 
<p>Get updates<br /> 
<a rel=""nofollow"" target=""_blank"" href=""https://www.formstack.com/forms/inets-mailing_list"">Sign up</a> to receive regular updates from the Microelectronics iNet</p> 
<p>Contact Us<br /> 
0117 32 86690<br /> 
<a href=""mailto:[email protected]"">[email protected]</a><br /> 
<a rel=""nofollow"" target=""_blank"" href=""http://www.inets-sw.co.uk/"">http://www.inets-sw.co.uk/</a></p>",Microelectronics iNet Launch,,publish,closed,closed,,,,,11/04/2012 10:04,11/04/2012 10:04,,0,http://www.mediwales.com/v3/?post_type=tribe_events&#038;p=5000,0,tribe_events,,0 
+0

你用什么来进行数据导入?任何应用程序或类似phpMyAdmin .... – 2012-04-11 13:37:54

+0

@SandeepRajoria是的,那正是 - phpmyadmin。 – Rob 2012-04-11 13:39:10

+0

好吧,你将不得不编辑csv来转义html字符...像php.net/manual/en/function.htmlspecialchars.php或导出数据库在sql中,如果你可以....因为我无法找到任何东西在phpMyAdmin中用于您的场景 – 2012-04-11 13:52:09

回答

1

确定在CSV文件中找到替换

取代'\' \\将在文件中逃脱单引号

然后 更换

"<p>'<p> \\放置文本字段在单引号

,然后更换

</p>"</p>' \\把文本字段用单引号

,然后尝试导入....它应该工作

+0

谢谢,我仍然收到错误。我应该找到并替换所有“与”? – Rob 2012-04-11 15:02:34

+0

不,不只是所有,但只有开始和结束...因此,对于MySQL把整个事情看作一个.. – 2012-04-11 15:08:11

+0

我试过我建议你回来之前,它似乎工作。只需双重检查一切。 – Rob 2012-04-11 15:16:44

1

嘿,我有同样的问题,试图更新我的西里尔hotel网站上的WordPress的帖子。

短期的解决方案是:

编辑csv文件后,“与““与 \”全部替换,保存文件,用记事本打开++查找和替换所有保存文件,你可以导入它使用下列选项phpMyAdmin的: enter image description here

(如果要替换当前职位替换文件签表数据) 分最重要的是**列逃脱:\ ** - 这将帮助的phpMyAdmin不能给你*错误“无效列线X CSV输入计数”

这里的整个过程一步步骤:

  1. 从phpmyadmin导出wp_posts表。
  2. 由于我直接用excel打开它时出现问题 - 首先应该打开Open Office,然后复制到Excel中。
  3. 完成编辑后,全部替换为”与”,然后另存为UNICOD TEXT。
  4. 用记事本打开++和替换所有选项卡,并将其保存为UTF-8(如果你不知道你怎么能与常规的记事本也做到这一点)
  5. 手动更改从延长。 TXT为.csv
  6. 用记事本打开++查找和替换所有“”,然后保存。
  7. 导入与上面的设置文件。

我花了一天的测试,但最后我明白了这一点。最好的部分是它也适用于西里尔字符。