2016-08-17 2 views
1

このライブラリhttp://pythonhosted.org/dbf/を使用してPythonを使用して.dpfファイルの1つの列を修正したいとします。
私はいくつかの列を印刷したいとき、それはうまく動作します。私は列を変更しようとしているときには、私が取得エラーDBFファイルを変更する

unable to modify fields individually except in with or Process()

マイコード:

ドキュメントで
table = dbf.Table('./path/to/file.dbf') 
table.open() 

for record in table: 
    record.izo = sys.argv[2] 

table.close() 

、彼らは

for record in Write(table): 

ようにそれを行うことをお勧めします。しかし、私はまた、取得エラー:

name 'Write' is not defined And:

record.write_record(column=sys.argv[2]) 

また

write_record - no such field in table

感謝することを私にエラーを与えます!

+1

'D(B)F'や' D(P)F':ここでは動作するはずカップルのオプションがありますか?あなたはあなたの質問の向こうに両方を使用しています –

+0

dbfモジュールをどのようにインポートしましたか?おそらくあなたはdbf.Write(テーブル)を使用する必要があります – rfkortekaas

+0

私はそれをインポートdbfを使用してインポートしました – Felder

答えて

1

ドキュメントの状態について私のご迷惑をおかけします。

table = dbf.Table('./path/to/file.dbf') 
# Process will open and close a table if not already opened 
for record in dbf.Process(table): 
    record.izo = sys.argv[2] 

または

with dbf.Table('./path/to/file.dbf') 
    # with opens a table, closes when done 
    for record in table: 
     with record: 
      record.izo = sys.argv[2] 
関連する問題