Python module unicodecsv
import unicodecsv def read_csv(filename): with open(filename, ‘rb’) as f: reader = unicodecsv.DictReader(f) return list(reader)
import unicodecsv def read_csv(filename): with open(filename, ‘rb’) as f: reader = unicodecsv.DictReader(f) return list(reader)
In Distributing your own package on PyPi I wrote about my first package on PyPI. Here are some refinements aka lessons learned: Project Description on PyPI I wondered why the project description on PyPi was empty. Solution: You need a long_description. If You already have a README.md, you can read it into a string and…
In Thoughts on building a library I introduced you to the concept of a personal library. In this part I will guide you through some issues I had with sorting and cataloging my library Categories After buying a ton of books over the last couple of years, I hadn’t figured out yet how to categorize…
When you finished reading part 1 of the introduction you might have wondered how to draw more than one line or curve into on plot. I will show you now. To make it a bit more interesting we generate two functions: sine and cosine. We generate our x-values with numpy’s linspace function import numpy as…
One of the things I always forget is date and time in Python. So message to myself: The strftime method is used for formatting (string_format_time) import datetime start_date = datetime.datetime.now() DATE_FORMAT = ‘%d/%m/%Y %H:%M’ print(start_date.strftime(DATE_FORMAT)) Her is a nice little Cheatsheet
Since Python 3.3 You can chain dictionaries which contain the same key in a prioritized order: from collections import ChainMap prio_1 = {“param_1”: “foo”} prio_2 = {“param_1”: “foobar”, “param_2”: “bar”} combined = ChainMap(prio_1, prio_2) print(combined[“param_1”]) # outputs ‘foo’ print(combined[“param_2”]) # outputs ‘bar’ The param_1 from the prio_1 dictionary is dominant, so it isn’t overwritten by…
Everyone is talking about error culture and that companies should embrace it. Jurgen Appelo sheds some light on this topic by bisecting the term “error” and introducing a tool to celebrate the right kind of errors. The grid The term “error” is broken down into mistake and failure. Mistake is a behavior, failure is an…
<=> is the NULL-safe equals operator SELECT * FROM reports WHERE NOT driver <=> user_id
This is part 2 of the 5 part series 15 Steps for successful Bootstrapping Time to Cash – When do I get my money? More important than “time to market” (when can I offer my product on the market) is “time to cash”: when do I get the money for my service? For a successful…