Read and write with file CSV in Python

[dropcap]I[/dropcap]t is possible to read and write CSV (comma separated values) files using Python 2.4 Distribution. Like most languages, file operations can be done with Python. Writing a CSV file with Python can be…

How to use urllib in Python

[dropcap]T[/dropcap]oday, with the development of the internet, network programming to exchange packets is no longer as complicated as it was a few decades ago. Python is no exception when it…

How to loop a dictionary in Python

Dictionary is one of the most widely used data structures in programming, especially with Python. To understand how to loop on it, extract its keys as well as retrieve all…

Using Feedparser in Python to read RSS

In this post, we will take a closer look at how to fetch and parse syndicated feeds with Feedparser library in Python. The detailed documentation of this library can be…

Running a simple http server

In the world of web engineering and development, developing web-based applications always need a web application server where all web pages are accommodated. Depending on what web technology as well…

Measure running time a routine in Python

I think this helps us a lot for estimation of how long a program runs in Python. When dealing with a huge amount of data, it takes long time. Showing…

Delete columns in numpy.array

a=array([[ 0, 1, 2, 3], [ 4, 5, 6, 7], [ 8, 9, 10, 11], [12, 13, 14, 15]]) delete(a, s_[1:3], axis=0) # remove rows 1 and 2 output: array([[…

Select column from a matrix

from operator import itemgetter nested_list = [[1, 2, 3], [10, 20, 30], [100, 200, 300]] map(itemgetter(1), nested_list) Result: [2, 20, 200]   Found it here: http://www.gossamer-threads.com/lists/python/python/770606

Array, List, etc. with String Indices

(Tiếng Việt) Trong lập trình, chúng ta cũng hay gặp nhiều trường hợp phải tạo một danh mục mà index của nó là các chuỗi kí tự. Có một khái niệm để mô tả loại đối tượng này, thường gọi là HashMap hay HashTable.

Counting how many times each string appears in a list

To count how many times a word appearing in a list of words, we can do as follows: