How to Merge dbf files?

المشرف العام

Administrator
طاقم الإدارة
I'm beginner in python and learning it with examples. I have 100s of dbf tables like

Type value1 value2 Type value1 value2 A 3 1 and A 5 7 B 4 2 A 6 8I want them to simply merged in single file like

Type value1 value2 A 3 1 B 4 2 A 5 7 B 6 8to get this from arcpy I used the code as below but it doesn't return any results or any errors. I have made "alldata.dbf" at that place with exact column to work with but the updateCursor doesn't update anything on that file. Can anyone help? or is it blunder to do thing like this in python instead of other easier method?

import arcpyarcpy.env.workspace = r'D:/dbflst/'dbfList = arcpy.ListTables()finalTable = r'D:/alldata.dbf'for dbf in dbfList:dbfFile = arcpy.env.workspace + '/' + dbfdbfData = {}# read in data from DBF and create dictionarywith arcpy.da.SearchCursor(dbfFile, ['Type','Value1','Value2']) as cursor: for row in cursor: dbfData[row[0]] = row[1]del cursor# write data from dictionary to final tablewith arcpy.da.UpdateCursor(finalTable, ['Type','Value1','Value2']) as cursor: for row in cursor: row[1] = dbfData[row[0]] cursor.updateRow(row)del cursor

أكثر...
 
أعلى