Showing posts with label learning. Show all posts
Showing posts with label learning. Show all posts

File management using openpyxl

When using openpyxl to load workbooks, ensure that your excel file is saved in the same folder as the .py file you are developing.

import openpyxl, pprintprint('Opening workbook... ')wb = openpyxl.load_workbook('censuspopdata.xlsx')sheet = wb.get_sheet_by_name('Population by Census Tract')
Otherwise, the following "file not found" error will result:

 "FileNotFoundError: [Errno 2] No such file or directory: 'censuspopdata.xlsx'"

Trouble Using Pip and Installing Openpyxl

Openpyxl is, according to Automate the Boring Stuff with Python, supposed to be a handy python library which allows programmers to use python programs with Microsoft excel sheets.

But first you need to install pip on your machine.

What is pip?
"Pip is a package manager for python packages. A package contains all the files you need for a module. Modules are Python code libraries that you can include in your project". - W3 schools. 

The first difficulty I had was getting pip to work through my command line.  I resolved that issue using paths - as described in this video (https://www.youtube.com/watch?v=Jw_MuM2BOuI).

The next issue I had was with installing openpyxl itself (which you need pip to do). I received the following error:
"Could not install packages due to an EnvironmentError: [Errno 13] Permission denied:"
"Consider using the `--user` option or check the permissions" 

Eventually, I found a solution on stackoverflow, which suggested using the following:
python -m pip install --user openpyxl
This worked.

Web Development: Organizing Files and Folders

When you begin to build your website, it's a very clever idea to organize  your files and folders efficiently. You should have: A ...