Python | Adjusting rows and columns of an Excel file using the openpyxl module

Learn examples from DataCamp guru:

We have created many interesting projects and programs in Python. Perhaps the time will come when we create something very interesting and we want to share it. Typically, to share our Python program, the recipient will need to have the same version of Python installed, as well as all the modules used. Well, that can be quite tedious to demand. The interest in converting to .exe is high enough for distribution and there are several options. In Python 2.7 Py2exe — great choice, and for Python 3, cx_freeze works pretty well.

CX_Freeze | .py to .exe

cx_Freeze is a set of freeze scripts and modules Python scripts to executables, in much the same way as do py2exe and py2app . Unlike these two tools, cx_Freeze is cross-platform and should work on any platform that Python itself runs on. It supports Python 2.7 or higher (including Python 3). 
First we need to download cx_Freeze: download from here or install it using pip:

Once we have cx_freeze, we`re ready to start. We`ll parse python.engineering with regex and urllib.

import urllib.request

import urllib.parse

import re

import time

 

 

url = ` https://www.python.engineering/ `

values ​​ = { `s` : `basics` ,

`submit` : `search` }

  

data = urllib. parse.urlencode (values)

data = data.encode ( `utf-8` ) # the data should be bytes

req = urllib.request .Request (url, data)

resp = urllib.request.urlopen (req)

respData = resp.read ()

  

paragraphs = re .findall (r `& lt; p & gt; (. *?) & lt; / p & gt;` , str (respData))

 

for eachParagraph in paragraphs:

  print ( eachParagraph)

 

time.sleep ( 14 )

Output: we added a 14 second sleep mode at the end so that we can run the executable and see the output before closing it. So let`s save this file as “reandurllib.py”. 

Now we create a second file called “setup.py”

from cx_Freeze import setup, Executable

 

setup (name = "GeeksforGeeks" ,

version = "0.1" ,

description = "",

executables = [Executable ( "reandurllib.py" )])

So, here we are importing from the installation and the executable cx_Freeze, then call the configuration function adding 4 parameters.

  1. name: this is the name we want our executable
  2. Version: just a version number to give it,
  3. description: all the details we want to provide (optional)
  4. Executable This is finally what we need to transform using the executable function and the path of the Python script to be converted as a parameter.

Then we open cmd.exe, or bash, or any other shell, go to the directory that contains the setup.py file and the conversion script and run:

 python setup.py build 

Now we are given a directory for assembly. Inside it we find another directory, and inside it — our executable! If everything went well, it should parse the search results basic with CX_Freeze

  • CX_Freeze Documentation
  • This article courtesy of Amartya Ranjan Saikia . If you are as Python.Engineering and would like to contribute, you can also write an article using contribute.python.engineering or by posting an article contribute @ python.engineering. See my article appearing on the Python.Engineering homepage and help other geeks.

    Please post comments if you find anything wrong or if you`d like to share more information on the topic discussed above.

    Learn examples from DataCamp guru: