Import pandas DataFrame from DBF file

dataframe_import_from_dbf

Skill - Import pandas DataFrame from DBF file

Table of Contents

Skills Required

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

References


Table of Contents

Comments

  1. How to write back records into the dbf file again?

    ReplyDelete
    Replies
    1. Hi 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

Post a Comment