2012-04-11 10 views
0

私はCSVとしてエクスポートしたカスタムデータベースを持っています。私は列とデータをWordpressデータベースの列に合わせて並べ替えたので、データをインポートすることができました。hpmを含むphpmyadminへのCSVファイルのインポート

唯一の問題は、カスタムデータベースの列の1つにHTMLが含まれていることです。これはデータがWordpressにCSVとしてインポートされるのを止めています。これを回避する方法はありますか?私は本当にHTMLを維持する必要があるので、何百もの行を再レイアウトする必要はありません。

データを最初に操作する形式にするにはしばらく時間がかかります。

p.s HTML列を使用せずにデータをインポートすると、Wordpressに正しくインポートされます。その後、

を置き換えるファイル内の単一引用符をエスケープします\' \\と'を交換

を置き換える見つけるcsvファイルで

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のようなもの.... –

+0

@SandeepRajoriaうん、それはちょうど - phpmyadmin。 – Rob

+0

あなたはcsvを編集してhtml文字をエスケープする必要があります。php.net/manual/en/function.htmlspecialchars.phpのようなもの、または可能ならばsqlのdbをエクスポートしてください...何かを見つけることができませんでしたあなたのシナリオではphpMyAdminで –

答えて

1

OK:ここ

は一例です "<p>'<p> \\テキストフィールドを配置する単一引用符、その後

</p>'

</p>"を交換\\単一引用符で

をテキストフィールドを配置し、インポートしようとするには....それは

+0

ありがとう、私はまだエラーが発生しています。すべての "with"を見つけて置き換えるべきでしょうか? – Rob

+0

いいえ、最初と最後だけではなくて... mysqlのためにすべてを扱います。 –

+0

あなたが戻ってくる前に私が提案したことを試しました。 – Rob

1

を動作するはずですねえ私が持っています私のキリル文字hotelウェブサイトのワードプレスの投稿を更新しようとしている同じ問題。

短いソリューションは、次のとおりです。

csvファイルを編集した後、「「すべて」を、「\ 」すべてを交換見つけメモ帳+ +を使用してファイルのオープンを保存して置き換えますファイルを保存し、あなたはそれが次のオプションでphpMyAdminをインポートすることができます。 enter image description here

(あなたが現在のポストを交換したい場合は、ファイルをチェックされているテーブルのデータを置き換え) の最も重要なのはされて**列がでエスケープ:\ ** - これはphpMyAdminのはあなたに*エラー*「ラインX上のCSV入力で無効な列数」を与えないのに役立ちます

ここでは、全体のプロセス工程によりですステップ:

  1. wpm_postsテーブルをphpmyadminからエクスポートする。
  2. 私はExcelで直接開く際に問題があります。まずOpen Open Officeで開いてからExcelにコピーしてください。
  3. 」を「」「」に置き換え、UNICOD TEXTとして保存してください。
  4. メモ帳で開き++とですべてのタブを交換し、(あなたはまた、通常のメモ帳でこれを行うことができます方法がわからない場合)UTF-8として保存
  5. 手動で拡張子を変更。 TXT検索と置換すべて「」で「し、その後、保存メモ帳+ +で
  6. オープンを.csvに。
  7. インポート上記の設定を使用してファイル。

それは一日かかりました最終的に私はこれを理解しました。最も重要な部分は、キリル文字でも動作することです。

関連する問題