For Developers

Automate your conversions using the RebaseData API

Read XLS with Python

At first make sure you have the PyPi package poster installed. On Ubuntu you can install it in the terminal like this:

apt-get install python-poster

Create a Python file example.py with the following code to read your XLS file. Don't forget to replace the example file paths with the actual ones.

from poster.encode import multipart_encode
from poster.streaminghttp import register_openers
import urllib2

# Register the streaming http handlers with urllib2
register_openers()

# Use multipart encoding for the input files
datagen, headers = multipart_encode({ 'files[]': open('file.xls', 'rb')})

# Create the request object
request = urllib2.Request('https://www.rebasedata.com/api/v1/convert', datagen, headers)

# Do the request and get the response
# Here the XLS file gets converted to CSV
response = urllib2.urlopen(request)

# Check if an error came back
if response.info().getheader('Content-Type') == 'application/json':
    print response.read()
    sys.exit(1)

# Write the response to /tmp/output.zip
with open('/tmp/output.zip', 'wb') as local_file:
    local_file.write(response.read())

print 'Conversion result successfully written to /tmp/output.zip!'

After running the command, try to open /tmp/output.zip. The archive contains CSV files that you can read easily with Python.

How does it work?

The RebaseData PHP-Client internally uses our API to convert the Microsoft Access XLS file to a standardized format. Then you can read the data using PHP as shown above.

Why use RebaseData?

  • Strong security.
  • Works with Windows, Mac and Linux.
  • Use an API to convert your databases.
  • Professional support.

Terms

  • We don't guarantee for the success or correctness of the conversion
  • You are only allowed to convert your own database files
  • By using RebaseData, you agree to our general terms