background preloader

Python

Facebook Twitter

Spreadsheet Document — ezodf 0.2.5 documentation. A spreadsheet is a computer application that simulates a paper, accounting worksheet. It displays multiple cells usually in a two-dimensional matrix or grid consisting of rows and columns. Each cell contains alphanumeric text, numeric values or formulas. A formula defines how the content of that cell is to be calculated from the contents of any other cell (or combination of cells) each time any cell is updated (ezodf has no calculation-engine included!). A pseudo third dimension to the matrix is sometimes applied as another sheet, of two-dimensional data.

Sheet Management A spreadsheet document should contain at least one Table object. Supported operations: append/insert new sheetsreplace existing sheetdelete existing sheets examples: Sheet Content Management The sheet content is managed by the Table class. All indices or size tuples are zero-based and have the form (row, column). metrics and property examples: get/set table data: row and column management: Warning. Fun with Lists. 11 Must-Read Blogs for Python Developers. Python is without question one of the most talked about programming language in this Universe. It’s everywhere, and because of how simple it is to learn it – many beginner programmers start their career with Python. The syntax of Python is very similar to that of English language, with the exception of a few extra characters here and there, but surely “future Python” is going to be even easier to learn and use for daily tasks.

I’m going to assume that you’ve got some experience with Python already, but even if you don’t – here’s an article to help you get started with Python, and here’s another one that lists all the Python IDEs you can try and work with. But, if you want to advance your skills a little further – these web scraping in Python tutorials might be of great help. It’s such a highly supported language right now, make the best of it. PyDanny This is a blog run by Daniel Roy Greenfeld, who currently works for Eventbrite, but has also worked for NASA in the past. Bite Sized effbot. The “Invent with Python” Blog | News about Al Sweigart’s programming books. I've written an article for OpenSource.com called APIs, not apps: What the future will be like when everyone can code, where I write about a coming future where programming ability is in the hands of everyone.

Excerpt: Despite this hype, I do think that coding will become a more widespread and routine skill in the years to come. Programmable technology will continue to pervade more parts of our life, computers will continue to become more accessible to a wider population, and the world will continue to become more complex. Understanding coding (and debugging) will naturally go with it....These are areas where non-programmers can significantly boost their productivity by learning to code. This is different from everyone becoming a software engineer. When I say learn to code, I don't mean develop software professionally. Inside the Head of PyDanny (Daniel Greenfeld)

5 Tutorials on Web Scraping in Python. Learning to program in Python is very easy. I think I made that perfectly clear in my article – resources for learning Python – a couple of months back. The language has a specific syntax that very much resembles the English language. It’s almost like you’re putting together real words to complete specific tasks. You’ll find those who’re more interested in learning Python programming language for the sake of tinkering with web frameworks, but then there are those – presumably You – who’re more into scraping things from the web, and then making that data look beautiful for everyone else to enjoy.

I recently published an article on web scraping tools, in which I discuss some of the most popular scraping apps and tools that have a GUI (Graphics User-Interface), so in turn being very accessible to beginners and lesser educated developers. Python Web Scraping Resource Jake Austwick has put together a great tutorial (resource) on how to get started with scraping in Python. Hidden features of Python. Python progression path - From apprentice to guru. COJ: Welcome message. Counter. A Counter is a container that keeps track of how many times equivalent values are added. It can be used to implement the same algorithms for which bag or multiset data structures are commonly used in other languages. Initializing Counter supports three forms of initialization. Its constructor can be called with a sequence of items, a dictionary containing keys and counts, or using keyword arguments mapping string names to counts.

The results of all three forms of initialization are the same. An empty Counter can be constructed with no arguments and populated via the update() method. The count values are increased based on the new data, rather than replaced. Accessing Counts Once a Counter is populated, its values can be retrieved using the dictionary API. import collections c = collections.Counter('abcdaab') for letter in 'abcde': print '%s : %d' % (letter, c[letter]) Counter does not raise KeyError for unknown items.

. $ python collections_counter_get_values.py a : 3 b : 2 c : 1 d : 1 e : 0. Python Performance Tips. This page is devoted to various tips and tricks that help improve the performance of your Python programs. Wherever the information comes from someone else, I've tried to identify the source. Note: I originally wrote this in (I think) 1996 and haven't done a lot to keep it updated since then. Python has has changed in some significant ways since then, which means that some of the orderings will have changed. You should always test these tips with your application and the version of Python you intend to use and not just blindly accept that one method is faster than another.

Also new since this was originally written are packages like Pyrex, Psyco, Weave, and PyInline, which can dramatically improve your application's performance by making it easier to push performance-critical code into C or machine language. If you have any light to shed on this subject, let me know. Contents Profiling Code The first step to speeding up your program is learning where the bottlenecks lie. Profile Module use #! Speed/PerformanceTips. This page is devoted to various tips and tricks that help improve the performance of your Python programs. Wherever the information comes from someone else, I've tried to identify the source.

Python has changed in some significant ways since I first wrote my "fast python" page in about 1996, which means that some of the orderings will have changed. I migrated it to the Python wiki in hopes others will help maintain it. You should always test these tips with your application and the specific version of the Python implementation you intend to use and not just blindly accept that one method is faster than another. See the profiling section for more details. Also new since this was originally written are packages like Cython, Pyrex, Psyco, Weave, Shed Skin and PyInline, which can dramatically improve your application's performance by making it easier to push performance-critical code into C or machine language. Other Versions Russian: Sorting. Python 101. Trevor Appleton: Converting and Resizing Images Using Python. As part of my wife's job a few years ago, she had to convert images from various file types to .jpg and then resize them to make them smaller.

Sure this could be done in programs like GIMP or Photoshop, but it was a time consuming process. To speed things up I wrote her a Python program which would automatically convert and resize any images which were in the same folder as the Python program. It saved her a lot of time. Since then there have been a number of occasion when I have had to convert images to .jpg and then resize them, such as when I am using eBay.

I always find this a cumbersome task, and often fall back on my Python program to do this for me. As I am sure this is something you will find useful I have made it the basis of my latest blog post. The program is quite simple, and does three things. Let us have a look at the whole program first and then we will go through it line by line. This is written in Python 2.7. ## Required Modulesimport Imageimport globimport os return None. Web Scraping with Scrapy - first steps. Imagine you want to extract content from the Web that isn't all in only one page: you need a way to navigate through the site to get to the pages that contain the useful information.

For example, maybe you want to get the latest "big questions" articles of the Mental Floss website, but only those in the Origins and Fact Check categories. If you have an interest in Python and web scraping, you may have already played with the nice requests library to get content of pages from the Web. Maybe you have toyed around using BeautifulSoup or lxml to make the content extraction easier.

Well, now we are going to show you how to use the Scrapy framework, which has all these functionalities and many more, so that solving the sort of problem we introduced above is a walk in the park. It is worth noting that Scrapy tries not only to solve the content extraction (called scraping), but also the navigation to the relevant pages for the extraction (called crawling). Pip install --upgrade scrapy Final words. How to Build a Kick-Ass Mobile Document Scanner in Just 5 Minutes - PyImageSearch. Remember my friend James from my post on skin detection?

Well, we grabbed a cup of coffee and some groceries yesterday at the local Whole Foods, all while discussing the latest and greatest CVPR papers. After I checked-out, I whipped out my iPhone and took a picture of the receipt – it’s just something that I like to do so I can easily keep track of where my money is going each month (like spending $20 on bacon, for instance). Anyway, James asked why I wasn’t using a document scanning app like Genius Scan or TurboScan to scan the receipt into my phone. Good question. I honestly hadn’t thought of it. But then James went to far… He bet me $100 that I couldn’t build a mobile document scanner app of my own. Well, the joke is on you, James. I’ll be collecting my $100 the next time I see you. Because honestly, document scanning apps are ridiculously easy to build. Genius Scan. You see, scanning a document using your smartphone can be broken down into three simple steps: Really. Sound interesting? Code golf - Tips for golfing in Python - Programming Puzzles & Code Golf Stack Exchange.

For ages it bothered me that I couldn't think of a short way to get the entire alphabet. If you use range enough that R=range is worth having in your program, then [chr(i+97)for i in R(26)] is shorter than the naive 'abcdefghijklmnopqrstuvwxyz' , but otherwise it's longer by a single character. It haunted me that the clever one that required some knowledge of ascii values ended up being more verbose than just typing all the letters. Until I saw this answer for My Daughter's Alphabet.