Support » Fixing WordPress » SimplePHPBlog import utility

  • I have been using SimplePHPBlog for many years and decided I wanted to use WordPress. I tried the RSS import feature but this simply didn’t work. So, I wrote a perl script to do it for me. Basically, it scans a SimplePHPBlog directory and stuffs all entries into the MySQL database in WordPress format.

    Download it here:
    http://www.qualtersystems.com/public/WordPress/WordPressImport.pl

    Hope it is useful – any feedback for bugs and improvements appreciated!

Viewing 15 replies - 1 through 15 (of 16 total)
  • What about a brief tutorial for the perl inept?

    My specs:

    Want to run this on a brand spankin new WP install
    SPHPBlog installed in /root

    Do I edit your login/pass info with my already set db info? And change where my SPHPBlog data is on the server?

    Great job, willhn !!
    This was just what I was looking for!
    I found only one problem… When I try to import a post with multiple categories, your program crashes. This is the error:

    Use of uninitialized value in concatenation (.) or strig at C:\path\WordPressImport.pl line 293.
    lost category '' at c:\Path\WordPressImport.pl line 293.

    Thanks!!

    Luisalcaraz,

    I experienced the same error and emailed William. He said he was going to look at the files I sent him and work on a fix. We are the first and second to try the script.

    However, looking with more detail now – the script gives me that error after importing about 7 posts. I double checked and none of these posts have multiple categories.

    What version of the sphpblog are you running? I was using 0.5.0.

    Hi teknics,

    I’m using 0.4.8
    I have the same error when the post has no category. You can check that.

    Luisalcaraz,

    I found one with no category as well, it was the 8th post. I fixed it and re-ran the script and it still gave me an error. William emailed me a script he repaired, and it got further – but still stopped way short of my total entries (a little more than half imported).

    There is a pretty big time difference between William and I, I believe he will be getting home from his “real” job in the next hour or so.

    Well – after rerunning the script, it imported all my posts. However, it still didn’t categorize the posts correctly. With 109 entries this will take forever.

    My next project, permalinks. How to get them pointing at the new posts.

    Just another update – Will suggested I drop the database and start from scratch and it worked flawlessly this time.

    I just need to figure out how to redirect all the old permalinks. He should be posting the new script anytime now, once he makes sure it’s 100% repaired.

    Hi! It works nice for me.
    Thank you very much!

    As far as I can see, this script only works, if the postings are just in text files, not but in zipped text files (*.txt.gz). I tried unpacking manually one posting and the import with the script works like a charm for this posting. So my question is, what do I have to change in the script to let it unpack the posting files first?

    EDIT:
    Right, I just found out myself: Adding

    /^(entry[\d-]+)\.txt.gz$/ && system("gunzip -fv $dir/$_");

    after line 623 in import_dir unzips the postings. I had to rerun the script afterwards to do the import, I’m sure there is a way to do it in one step, but I don’t know much Perl and that did the trick for me. Thanks for the cool script!

    tmphillips

    (@tmphillips)

    i am going to try this.. wish me luck.. 😉

    tmphillips

    (@tmphillips)

    i dont have a clue yet how to do this, but knowing that my entries are all gzipped, I was looking at missmarple’s post, and then comparing to the downloaded code, and I am guessing that the script has changed a bit because it doesn’t look right to add the line at 624. Instead look in that section, and add it after the import_dir line (?):

    -d "$dir/$_"             && $self->import_dir ("$dir/$_");
    /^(entry[\d-]+)\.txt.gz$/ && system("gunzip -fv $dir/$_");
    /^(entry[\d-]+)\.txt$/   && $self->add_post("$dir/$1");

    hello!
    thanks for this featurerich script.

    i’m not that perl savvy so i post here for help:

    i run into this problem:

    ...
    Added post 'some super title' with 0 comments
    DBD::mysql::st execute failed: Duplicate entry '6-1' for key 1 at ./WordPressImport.pl line 497.
    DBD::mysql::st execute failed: Duplicate entry '6-1' for key 1 at ./WordPressImport.pl line 497.

    then i reexecute the script and it seems to work for some posts.
    it keeps telling me that the post i already imported are already there…
    every 2nd or third post sometimes less i get this

    ...
    Added post 'some title' with 0 comments
    DBD::mysql::st execute failed: Duplicate entry '15-1' for key 1 at ./WordPressImport.pl line 497.
    DBD::mysql::st execute failed: Duplicate entry '15-1' for key 1 at ./WordPressImport.pl line 497.

    after

    for ((i=0;i<100;i++)); do ./WordPressImport.pl [...allthe flags...]; done

    it gets stuck here:

    Post exists: 'my super title...'
    Use of uninitialized value in join or string at ./WordPressImport.pl line 484.
    Use of uninitialized value in substitution (s///) at ./WordPressImport.pl line 272.
    Use of uninitialized value in join or string at ./WordPressImport.pl line 495.
    Use of uninitialized value in join or string at ./WordPressImport.pl line 495.
    DBD::mysql::st execute failed: Column 'post_content' cannot be null at ./WordPressImport.pl line 497.
    DBD::mysql::st execute failed: Column 'post_content' cannot be null at ./WordPressImport.pl line 497.

    i have no idea where to look for the failure.

    maybe it is the use of the

    [html] [/html]

    tags or other…
    please
    any help is apreciated
    thx
    flowolf

    SOLVED!
    *fuuuuh* the script does not tolerate entries that start with an empty line!
    plus i had to run it over and over again to get all the posts imported.

    thx for the script. still helped a lot!

    it seems the first errors occur when the script has problems with tags of posts…

    still not solved too well… there is too much handwork left. almost every posting has to be edited. this is too much for 300+ posts.

Viewing 15 replies - 1 through 15 (of 16 total)
  • The topic ‘SimplePHPBlog import utility’ is closed to new replies.