Skip to main content

Posts

Showing posts from March, 2016

xlrd python module for reading spreadsheets - Read the docs

xlrd module is a python module and is used for working with excel files or sprea dsheets . If you have seen the title I have named this post with Read the docs at the end. Do you k now why? python xlrd module documentation/tutorial Okay I will tell it to you. The first time I used python I got in love with this programming language the same way you fell in love with it. But one day I wanted to convert data in excel sheet to a dictionary for my computations. I thought that I could consider excel sheets as python file objects and proceed with computation. But th is method of using e xcel fi les as file o bjects didn 't work .  So I typed " Excel with python " in google and the results I saw were these: Google results for "Excel with python"  I chose the second result because the name( title ) was obvious and I found the xlrd module . I clicked on the documentations and expected this kind of documentation: Read the docs documentation s

The XLRD python module for reading data in spreadsheets - Quickstart

In the previous post we have seen, how to install xlrd module . If you already have xlrd module installed on your computer then go ahead with this section other wise install the module having a look from here: The xlrd python module for reading excel spreadsheets - Installation . Eager to get started?This post will give you a good introduction to get started with the xlrd . First make sure that xlrd is installed on your computer. $ pip freeze . Check if xlrd is present in the list. xlrd is up-to-date. In IDLE   xlrd.info.__VERSION__ to see the version and check if you are up-to-date. Lets get started with something simple. Terminology Excel files are also called as workbooks or simply books . Also there can be n number of sheets in a given workbook .  Sheets in Excel File or workbook A cell is a box which contains only one entry or a single piece of data. Cell in Excel Worksheet A row is a horizontal group of cells. Row in Excel worksheet A column

The XLRD python module for reading excel spreadsheets - Installation

In the last post we have seen the introduction of the xlrd module. If you have missed it, you can see it from here: The XLRD python module for reading spreadsheets files - Introduction . We have seen the problems xlrd development team faced with the dates stored in the spreadsheets and the encoding.  In this post on Installation we will see how to install the module using pip , easy_install , virtualenv and manual installation .  Installation xlrd module doesn't depend on any third party libraries other than python standard library .  pip If you want to use pip to install the xlrd package then you can do as follows: $ pip install xlrd easy_install You can also install the xlrd package using easy install as follows: $ easy_install xlrd virtualenv You might sometimes have experienced that you want to install two libraries with same name or different versions of the same library. Also you don't want to install certain package to the whole computer but to

The XLRD python module for reading the spreadsheet documents - Introduction

xlrd module for python is an awesome module  and I think it is a must for each and every pythonist to have a basic knowledge of this module . This module reads the data in the excel sheets or sometimes called as spreadsheets and thus the data can be used for computation(s) in our python scripts. But a serious problem I have faced is, when I wanted to use this module it had a documentation which was not in the style of readthedocs . There was one xlrd readthedocs but at the time of writing this post it was empty. Eventhough I searched the internet( google ) and have learnt on this module myself, I wanted to create and share my knowledge as a documentation for this module in the form of readthedocs not using the sphinx but manually writing each and everything. A harley davidson style. Encoding used This module(xlrd) uses unicode encoding . It is known that from Excel 97 onwards the data is stored in unicode format but the prior versions had some other encoding . But

How to read data from excel or spreadsheet file with Python

We all are used to managing data using Excel sheets or spreadsheets , sometimes it becomes necessary for us to use the data stored in excel sheet for some computations using python .  In this tutorial we will be reading the data in an excel file using python xlrd module . According to official documentation at pypi xlrd is: xlrd module is a library to extract data from Excel sheets or spreadsheet files. Before we start we will have to install this module so that it can be used in our python script . If you have not yet installed this module on your computer then you can do the following: $ pip install xlrd You can also install using easy_install or by downloading the package from pypi , all of them have the same effect. We will start with IDLE so that we can understand each and every command in the interpreter easily. We will using roc.xls  for this tutorial and the spreadsheet(roc.xls) contains the following data: Roll Number Name Marks Rank 1 Pearson 86

Making a quiz web app with python and flask

Edit : When you are creating a web app with h tml templates, then y ou will have to sa ve the html file in templates folder in the Current Wor ki ng Directory( CWD). If you save the file in the C W D directl y you will get a TemplateNotFound error. Thank you Udhay for pointing it out.   In this post we will create a quiz website using python . I will be using the flask framework . After reading this tutorial you will learn form submission , flask templates , python code in flask templates , shuffling the questions and options with the random module and few others.  Please note that this tutorial is not big as it seems to be. Some of the code has been rewritten to maintain consistency and also font size is somewhat big so that your eyes won't get stressed reading this tutorial. Also the content has not occupied the full width of the page. In this tutorial I am assuming that you are having a very basic understanding of the flask framework . Please refer the documentation