How to Convert a DBF to a CSV in Python?

Background 💡 A dBase database file (DBF) is a database file format with the .dbf file extension used by various applications and database systems. 💡 A comma-separated values (CSV) file is a text file that uses a comma to separate fields of a data record (=line). Problem Formulation Given a .dbf file my_db.dbf. How to … Read more

How to Convert a CSV.gz to a CSV in Python?

To convert a compressed CSV file (.csv.gz) to a CSV file (.csv) and read it in your Python shell, use the gzip.open(filename, ‘rt’, newline=”) function call to open the gzipped file, the file.read() function to read its contents, and the file.write() function to write the CSV in a normal (unzipped) file. The gzip.open() function has … Read more

How to Convert a List of Dicts to a CSV File in Python [4 Ways]

Problem: How to convert a list of dictionaries to a csv file? Example: Given is a list of dicts—for example salary data of employees in a given company: Your goal is to write the content of the list of dicts into a comma-separated-values (CSV) file format. Your out file should look like this: my_file.csv: Name,Job,Salary … Read more

3 Simple Steps to Convert calendar.ics to CSV/Excel in Python

Step 1: Install csv-ical Module with PIP Run the following command in your command line or PowerShell (Windows) or shell or terminal (macOS, Linux, Ubuntu) to install the csv-ical library: In some instances, you need to modify this command a bit to make it work. If you need more assistance installing the library, check out … Read more

How to Sort Words Alphabetically in Python

Problem Formulation and Solution Overview In this article, you’ll learn how to sort words alphabetically in Python. To make it more fun, we have the following running scenario: Some English sayings, also known as Tongue-Twisters, are fun to try and say quickly. They are also used to improve non-English speaking individuals and small children’s fluency … Read more

Python CSV to UTF-8

This article concerns the conversion and handling of CSV file formats in combination with the UTF-8 encoding standard. 💡 The Unicode Transformation Format 8-Bit (UTF-8) is a variable-width character encoding used for electronic communication. UTF-8 can encode more than 1 million (more or less weird) characters using 1 to 4 byte code units. Example UTF-8 … Read more

How to Read and Convert a Binary File to CSV in Python?

To read a binary file, use the open(‘rb’) function within a context manager (with keyword) and read its content into a string variable using f.readlines(). You can then convert the string to a CSV using various approaches such as the csv module. Here’s an example to read the binary file ‘my_file.man’ into your Python script: … Read more

How to Convert Epoch Time to Date Time in Python

Problem Formulation and Solution Overview In this article, you’ll learn how to convert Epoch Time to a Date Time representation using Python. On January 1st, 1970, Epoch Time, aka Time 0 for UNIX systems, started as a date in history to remember. This date is relevant, not only due to this event but because it … Read more

Python Package Version: the __version__ Attribute

Python __version__ Attribute Python contains many “Magic Methods/Attributes”. One of these is __version__ commonly called “Dunder version” because of the double underscore before and after version. In this article, I will briefly look at what a Dunder Method/Attribute is and talk about __version__. What Does a Dunder Method/Attribute Do? Dunder Methods/Attributes, also called “Magic Methods” … Read more