type in your query to search makeyougohmm
Things that ... make you go hmmtechnology music video art news reviews and muse on the web

July 1, 2005

[free code] How to import from Pivot 1.2x to Wordpress 1.5x

How To — by TDavid @ 2:10 am PST
F = please no more posts like thisD = not among your best stuffC = average postB = good post, I liked itA = great post, please create more like this (2 votes, average: 1 out of 5)
Loading ... Loading ...

CHANGELOG
Update 11/3/2005: v0.2 of the Pivot to WP importer is now available for download with the following changes/fixes:

- two database table name fixes (thanks sepp)
- added MySQL hostname variable to config area
- WP “more” code for intro / body compliance (thanks paradoxdruid)
- changed use of file_get_contents for older versions of PHP

Paradoxdruid noted on the Wordpress support he tested this importer with v1.3 beta 1 of Pivot. If anybody finds a version that breaks the program please use the comments section and tell me about it.

Original post
A couple months ago MakeYouGoHmm switched from Pivot 1.2x to Wordpress 1.5x. At the time of the switch I didn’t find an importer script to automate moving all the blog posts and comments from Pivot 1.2x to Wordpress 1.5x, so I wrote my own in PHP. After completing the import I asked if anybody else was interested in the code and recently a couple folks commented that they were interested. I promised that I would share the code, so here it is:

Requires: Linux, PHP and MySQL
Download pivot 1.2x to Wordpress 1.5x importer (5k ZIP)

The package includes pivot_to_wp1-5.php which has a small configuration area required before running the program and a small readme.txt file. There is no support offered for this program, but if you have questions about the code feel free to use the comment area in this thread only or trackback from your blog and I will probably respond when I get a few minutes.

I’m still using Pivot on a couple blogs so I might be using this code again someday. Hope others find it as useful as I did a few months ago.

Update 7/1/05: Omitted an important point that this importer is for *Linux* server compiled with PHP, not Windows or Mac and a working MySQL database is required (if Wordpress is installed and running then all is well). Somebody will need to write a conversion for those OS.

Related Posts

RSS Feed comments for this post 40 Comments »

  1. Hi TDavid!
    Thanks for the script.

    Tried it! Didn’t work I am fraid.:(
    I am usin IIS server.
    I used the default “/pivot/db” path. (pivot is in c:\inetpub\wwwroot\pivot.)

    Heres the error message:

    Warning: opendir(/pivot/db): failed to open dir: Invalid argument in c:\inetpub\wwwroot\pivot_to_wp1-5.php on line 94

    Warning: readdir(): supplied argument is not a valid Directory resource in c:\inetpub\wwwroot\pivot_to_wp1-5.php on line 96

    Warning: closedir(): supplied argument is not a valid Directory resource in c:\inetpub\wwwroot\pivot_to_wp1-5.php on line 105

    Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in c:\inetpub\wwwroot\pivot_to_wp1-5.php on line 111

    Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in c:\inetpub\wwwroot\pivot_to_wp1-5.php on line 119

    Warning: Invalid argument supplied for foreach() in c:\inetpub\wwwroot\pivot_to_wp1-5.php on line 124

    Comment by Salakala — July 1, 2005 @ 5:03 am PST

  2. The code is in PHP for a *Linux* server, Salakala, I should have mentioned that very important point, sorry. Probably will need more than a little effort to make it work with IIS. You’ll need somebody to write a conversion for IIS.

    Also, this is incorrect:
    I used the default “/pivot/db” path. (pivot is in c:\inetpub\wwwroot\pivot.)

    The default path to the “db” directory is not the root path of Pivot. The db directory in Pivot is a subdirectory and contains the 000001.php, 000002.php etc files that the script iterates through.

    Note: I’ve updated the main text to indicate it’s for Linux servers running PHP with MySQL. My suggestion is get some Linux hosting with PHP/MySQL and you will be all set :)

    Comment by TDavid — July 1, 2005 @ 9:36 am PST

  3. Hi! Thanks for the effort so far!

    A) Would it work on Apache running on windows?

    B) If my db folder is situated at: C:\Apache\Htdocs\Pivot\db and your nifty script is @
    C:\Apache\Htdocs\pivot_to_wp1-5.php what should the ($pivot_db_path = ”;) line look like?

    Thanks

    Salakala

    Comment by Salakala — July 1, 2005 @ 5:38 pm PST

  4. thanks for the script, TDavid :)

    there were actually some little “erratums”: using tablenames wasn’t 100% the same through the script. sometimes a tablename included _ and sometimes not. after fixing this the script worked like a charm. thanks again :)

    Comment by sepp — July 13, 2005 @ 4:24 pm PST

  5. …and you might want to use this: http://wiki.wordpress.org/UpdatePostSlugs
    to generate post slugs (works with 1.5, too) :)

    Comment by sepp — July 13, 2005 @ 4:54 pm PST

  6. […] If you’ve noticed the number of posts in this blog, you’ve probably seen that the number of uncategorized posts has grown. That because I used a script (h/t Robust McManlyPants) to convert my old blog entries to this new one. I thought I followed all the instructions correctly, but I lost my categorizations so I have to go fix them o…n…e … b…y … o…n…e. So all my old stuff can be found here. w00t! […]

    Pingback by Random John reloaded » About that growing archive list and all those uncategorized posts — September 14, 2005 @ 10:33 am PST

  7. I had to change ‘_users’ to ‘users’ on line 111 and ‘_categories’ to ‘categories’ on line 119, as a previous commenter suggested, as well as specify my database location instead of localhost on line 90.

    Once I did that, it worked perfectly! Thank you very much for making this tool!

    Comment by Paradoxdruid — October 27, 2005 @ 1:42 am PST

  8. I changed one more thing… on line 159, I replaced:
    $post_content = addslashes($check_it[’introduction’]) . addslashes($check_it[’body’]);

    with
    $post_content = addslashes($check_it[’introduction’]) . “” . addslashes($check_it[’body’]);

    This inserts the “more” tag into each entry, so WordPress will display introductions correctly.

    Thanks again for a great framework!

    Comment by Paradoxdruid — October 27, 2005 @ 2:16 pm PST

  9. Dang it, the added section got processed and removed.. between the “” on the modifed line is (without spaces)

    Comment by Paradoxdruid — October 27, 2005 @ 2:17 pm PST

  10. It still removed it. *sigh* In any case, it’s the WordPress “more” tag

    Comment by Paradoxdruid — October 27, 2005 @ 2:18 pm PST

  11. I am trying to run your script and I keep getting this error:

    processing … /home/zez/pivotblog/pivot/db/standard-00000/00082.php

    Fatal error: Call to undefined function: file_get_contents() in /home/zez/wordpress/pivot_to_wp1-5.php on line 130

    Any ideas? I know nothing about php programming so I don’t know where to start to fix it.

    Comment by Kevin — November 3, 2005 @ 2:17 pm PST

  12. Hi Kevin -

    file_get_contents() is only available in PHP version 4.30 and forward. Your host must be using an older version of PHP that doesn’t support that function.

    Two possible solutions here:
    1) get your hosting company to upgrade PHP on their servers
    2) There is a workaround, however, just use the following code:

    Change this line:
    $entry_data = file_get_contents(”$pivot_db_path/$parent_each/$each”);

    To read as follows:
    $entry_data = implode(”, file(”$pivot_db_path/$parent_each/$each”));

    Comment by TDavid — November 3, 2005 @ 3:45 pm PST

  13. Thanks for the info! Since I’m hosting it on my own server I could upgrade PHP, or change the code. I’ll try changing the code first. :)

    But implode sounds a bit scary. heh

    Comment by Kevin — November 3, 2005 @ 4:55 pm PST

  14. I have another question since I’m getting a parse error on line 130. What are the characters before file? (’’, file(

    Comment by Kevin — November 3, 2005 @ 5:10 pm PST

  15. Don’t copy/paste the lines from above, Kevin, they are adding the wrong quote characters. Instead, type the code out and use the double quote and single quote (to the left of the enter key).

    Comment by TDavid — November 3, 2005 @ 5:21 pm PST

  16. Kevin - If you haven’t already got it fixed up, I just uploaded a v0.2 of the script that has that change as well as a few mentioned by others earlier in this thread (sepp and paradoxdruid).

    LMK how it works out for you :)

    Comment by TDavid — November 3, 2005 @ 8:23 pm PST

  17. I hate to be a bother but I’m still having issues.
    I replaced
    $entry_data = file_get_contents(”$pivot_db_path/$parent_each/$each”);
    with
    $entry_data = implode(’file(”$pivot_db_path/$parent_each/$each”));

    Is that correct? I don’t get the parse error on line 130 anymore but now I get a parse error on line 134 which seems to be this line

    $dateparts = explode(”-”, $check_it[’date’]);

    I’m using php 4.1 if that makes a difference. Thanks again for all the help!

    Comment by Kevin — November 3, 2005 @ 10:08 pm PST

  18. Did you see I included a new download version above? It contains the code fix, Kevin. Use that :)

    Comment by TDavid — November 3, 2005 @ 10:18 pm PST

  19. Never mind. After posting I saw there was an updated version and it seemed to work fine. Thanks again for the script!

    Comment by Kevin — November 3, 2005 @ 10:23 pm PST

  20. […] With many many MANY thanks to this site I was able to use a script to convert pivot to wordpress. […]

    Pingback by I’m Not a Slacker » Blog Archive » New and Improved — November 3, 2005 @ 11:11 pm PST

  21. […] Dus Wordpress werd het logische alternatief (weer voor de nerd). Maar hoe krijg je Pivot postings gemakkelijk over naar Wordpress? Dat bleek niet zo moeilijk, aangezien Things That Make You Go Hmm het probleempje al eerder getackeld had. Click and play. […]

    Pingback by Remondo » Pivot naar Wordpress — November 6, 2005 @ 4:06 pm PST

  22. hello, i´d like to thank you for that script. it´s not easy to leave the pivot community, cause pivot is still a great blogger tool. it´s a pity, that pivot is not that supported by diverse blogger tools, like wordpress is.

    grz brs

    Comment by breskeby — November 23, 2005 @ 4:21 pm PST

  23. […] I had commented on an earlier post that I wanted to move on from the Pivot blogging software into WordPress. I had tinkered with WordPress just a little bit, on a client’s site, and I found it to be much easier to manage than Pivot. Also, there’s the issue with themes. Pivot is ridden with some seriously fugly theme action. WordPress, on the other hand, also has some pretty nasty themes, but does have a broader variety, which lends itself to much nicer-looking themes (like this one). So, even though I had estimated that I’d be making the move to WP some time early next year, I decided to get that over with tonight. An awesome little php script made the migration of posts almost a snap (special characters weren’t transfered correctly, and a few other minor details). […]

    Pingback by A. B. Logg » From “painstakingly awkward” to “not too shabby” — November 25, 2005 @ 11:57 pm PST

  24. Hi TDavid

    Some little techie stats I used your script on my Mac running OsX with Apache 1.3.33, PHP 5.0.2 and MySQL 4.1.7-standard

    And I converted my old Pivot - 1.14.1: ‘Soundwave’ DB to Wordpress 1.5.2 and as far as I can see it converted all 150 or so posts without any changes to your code.

    I’ve only got one little remark I miss the images and have to fix that by hand or some smal script, but the most important thing all my posts are back online !!!

    Many Thanx !!

    Comment by Squit — December 4, 2005 @ 6:25 pm PST

  25. […] Met behulp van dit script Pivot_to_wp02 lukte het om mijn oude 1.14.1 Pivot archief om te zetten naar Wordpress 1.5.2 […]

    Pingback by Squit | Sebastiaan Smid » Blog Archive » Het Archief — December 4, 2005 @ 6:31 pm PST

  26. […] Couple that with the fact that the Pivot-to-Wordpress script reached version 2.0 and in a test run it processed everything cleanly without the funky line-breaks from the time before? Yeah. I was sold. […]

    Pingback by Robust McManlyPants on Average Display » The New Look — December 15, 2005 @ 8:57 pm PST

  27. […] Zoals misschien duidelijk heb ik net (op een half uurke) Wordpress kunnen installeren! Perfect is het zeker nog ni en het tooltje om van pivot naar Wordpress posts over te zetten werkt ook niet altijd perfect maar toch acceptabel! Als er dus nog mensen willen overschakelen, ik weet hoe! […]

    Pingback by 14k.be » Blog Archive » Wordpress — December 16, 2005 @ 9:35 am PST

  28. […] Heb met een scripje alles uit flatbek kunnen importeren, nu nog ff de dubbele posts verwijderen de foto`s toevoegen, de links vertalen en linken en wat nog niet meer, maar ben voorlopig wel tevreden…. […]

    Pingback by foodblogger.nl » Nieuwe Foodblog! — December 19, 2005 @ 3:19 pm PST

  29. Tnx guys, this spared me more than a few days… :)

    maybe a good idea to put this in to:
    $result = mysql_query(”SELECT comment_post_ID , count(*) FROM `wp_comments` GROUP BY comment_post_ID;”, $mysql_link);
    while (list($post, $comments) = mysql_fetch_array($result)) mysql_query(”update wp_posts set comment_count = ‘$comments’ where ID = ‘$post’”);

    (at the end of the script, or in a separate script)

    this wil fix the comment count…

    Comment by Maverick — January 16, 2006 @ 8:18 am PST

  30. Is it just me or is the link to the download not working? Please take a look at it and let me know. I’d really need this script.

    Comment by Marty McFly — March 10, 2006 @ 10:17 am PST

  31. Nope Marty, wasn’t just you. I fixed the download program, all is well now. Thanks for the head’s up :)

    Comment by TDavid — March 11, 2006 @ 8:03 am PST

  32. HI,

    I am using the above file i.e pivot to wordpress but there are certain files which the scipt is unable to process, it doesn’t show any error but it is unable to covert the database into mysql script, can anyone please guide me about this…

    Regards,
    Pankaj

    Comment by Pankaj Malhotra — April 16, 2006 @ 11:46 pm PST

  33. Hello Pankaj - which version of pivot are you using and what version of WP are you upgrading to? This importer was designed and tested to work with Pivot 1.2x to Wordpress 1.5x and may not work with other configurations. I haven’t tested any others anyway.

    Comment by TDavid — April 17, 2006 @ 12:00 am PST

  34. Hi David,

    I am working on the same version only.
    There is a folder in my db i.e standard-00002 which when i unserialize it gets unserialized, but there is another folder standard-00011 which is not getting unserialized if done manually, I could not understand where the problem is..Due to which the script is also unable to work on that
    Can you put some light on it..

    Regards,
    Pankaj

    Comment by Pankaj Malhotra — April 17, 2006 @ 12:17 am PST

  35. Probably not if you continue to get my name wrong :) I promise not to call you ankaj.

    Comment by TDavid — April 17, 2006 @ 12:30 am PST

  36. Hi TDavid,

    Srry for that.
    So, you don’t have any idea why is this so….

    Regards,
    Pankaj

    Comment by Pankaj Malhotra — April 17, 2006 @ 12:57 am PST

  37. Pankaj - I’m still waiting for you to answer my initial question: what version of each are you using? Pivot and Wordpress, and sorry, this doesn’t answer my question: “I am working on the same version only.”

    If you are using any other version than what was tested then that leaves me out of the loop because I don’t use current versions of Pivot any longer so I have no idea what they might have changed in their data structure.

    With that said, if you can unserialize the data manually but can’t do it from the web then there must be something else amiss. Permissions perhaps?

    Comment by TDavid — April 17, 2006 @ 1:04 am PST

  38. I am working on pivot ver. 1.24.3 and wordpress ver 1.5.2 .

    I don’t know why is this happening some database are able to unserialize and some are not.

    Actually my major concern is to transfer the data into the movable type from pivot..

    Comment by Pankaj Malhotra — April 17, 2006 @ 1:13 am PST

  39. “Actually my major concern is to transfer the data into the movable type from pivot.”
    Wrong importer then, you need to use a Movable Type importer. Consult with Six Apart.

    Comment by TDavid — April 17, 2006 @ 1:48 am PST

  40. Hi

    One of my friends has been using Pivot for a very long time and he is now planing a awitch to Wordpress. Is there any way to get this importer work in Wordpress 2.x series. I suggested importing to WP 1.5x and then upgrade it to latest WP. Is there any other ways?

    Comment by Joe — April 15, 2008 @ 11:46 am PST


TrackBack URI: http://www.makeyougohmm.com/20050701/2103/trackback/

Leave a comment


By leaving a comment you consent to the Official Hmm Comment Policy

Return Home


Copyright 2003-2008 KMR Enterprises All Rights Reserved