Reading DBF files with pyodbc

后端 未结 3 410
梦如初夏
梦如初夏 2020-12-18 08:00

In a project, I need to extract data from a Visual FoxPro database, which is stored in dbf files, y have a data directory with 539 files I need to take into account, each fi

3条回答
  •  悲哀的现实
    2020-12-18 08:28

    I know this doesn't directly answer your question, but might still help. I've had lots of issues using ODBC with VFP databases and I've found it's often much easier treating the VFP tables as free tables when possible.

    Using Yusdi Santoso's dbf.py and glob, here's some code to open each table in a directory and run through each record.

    import glob
    import os
    import dbf
    
    os.chdir("P:\\data")
    for file in glob.glob("*.dbf"):
        table = dbf.readDbf(file)
        for row in table:
             #do stuff
    

提交回复
热议问题