Skill - Import pandas DataFrame from DBF file
Skills Required
- Setup python development environment
- Basic Printing in Python
- Commenting in Python
- Managing Variables in python
- Pandas DataFrame Basics
Please make sure to have all the skills mentioned above to understand and execute the code mentioned below. Go through the above skills if necessary for reference or revision
In this post, we will learn how to import dataframe from a `dbf` file
In order to import dataframe from dbf file, we require simpledbf module.
Install simpledbf using the command pip install simpledbf
Example
# import pandas module
import pandas as pd
# import Dbf5 module from simpledbf module
from simpledbf import Dbf5
# path of dbf file
dbfPath = r'C:\Users\Nagasudhir\Documents\test.dbf'
# load the dataframe from dbf file path
df = Dbf5(dbfPath).to_dataframe()
The file used in this example can be downloaded from here
Video
Video for this post can be found here
Online Interpreter
Although we recommend to practice the above examples in Visual Studio Code, you can run these examples online at https://www.tutorialspoint.com/execute_python_online.php
How to write back records into the dbf file again?
ReplyDeleteHi Shubas, Looks like there is no easy way to create a dbf file from pandas dataframe, may be this stackoverflow solution can help you - https://gis.stackexchange.com/a/288543
Delete