Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6061609
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T08:57:24+00:00 2026-05-23T08:57:24+00:00

I am trying to build a offline wiktionary using the wikimedia dump files (.xml.bz2)

  • 0

I am trying to build a offline wiktionary using the wikimedia dump files (.xml.bz2) using Python. I started with this article as the guide. It involves a number of languages, I wanted to combine all the steps as a single python project. I have found almost all the libraries required for the process. The only hump now is to effectively split the large .xml.bz2 file into number of smaller files for quicker parsing during search operations.

I know that bz2 library exists in python, but it provides only compress and decompress operations. But I need something that could do something like bz2recover does from the command line, which splits large files into a number of smaller junks.

One more important point is the splitting shouldn’t split the page contents which start with <page> and ends </page> in the xml document that has been compressed.

Is there a library previously available which could handle this situation or the code has to be written from scratch?(Any outline/pseudo-code would be greatly helpful).

Note: I would like to make the resulting package cross-platform compatible, hence couldn’t use OS specific commands.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T08:57:25+00:00Added an answer on May 23, 2026 at 8:57 am

    At last I have written a Python Script myself:

    import os
    import bz2
    
    def split_xml(filename):
        ''' The function gets the filename of wiktionary.xml.bz2 file as  input and creates
        smallers chunks of it in a the diretory chunks
        '''
        # Check and create chunk diretory
        if not os.path.exists("chunks"):
            os.mkdir("chunks")
        # Counters
        pagecount = 0
        filecount = 1
        #open chunkfile in write mode
        chunkname = lambda filecount: os.path.join("chunks","chunk-"+str(filecount)+".xml.bz2")
        chunkfile = bz2.BZ2File(chunkname(filecount), 'w')
        # Read line by line
        bzfile = bz2.BZ2File(filename)
        for line in bzfile:
            chunkfile.write(line)
            # the </page> determines new wiki page
            if '</page>' in line:
                pagecount += 1
            if pagecount > 1999:
                #print chunkname() # For Debugging
                chunkfile.close()
                pagecount = 0 # RESET pagecount
                filecount += 1 # increment filename           
                chunkfile = bz2.BZ2File(chunkname(filecount), 'w')
        try:
            chunkfile.close()
        except:
            print 'Files already close'
    
    if __name__ == '__main__':
        # When the script is self run
        split_xml('wiki-files/tawiktionary-20110518-pages-articles.xml.bz2')
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Trying to build the following simple example #include <boost/python.hpp> using namespace boost::python; tuple head_and_tail(object
Im trying to build a little site using XML instead of a database. I
I'm trying to build a C++ extension for python using swig. I've followed the
Im trying to build call to action button on my site using jQuery. I
I am trying build a DataTable one row at a time using the following
Trying to build a marquee control with smooth text animation. Current efforts include: Using
Im trying to build and automated log in using Googles authSub, but I need
I'm trying build a conditions array to be using in a prepared statement: Cars.find(:all,
I am trying to build an iPhone web application using ASP.NET. The page is
I am trying to build a facebook WebApp in vb.net using the Facebook C#

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.