How can I change FITID in an ofx file using ofxparse?

351 Views Asked by At

When I debug my code, the changes happen, but when I open the file, nothing was changed.

Code

from ofxparse import OfxParser
from datetime import datetime as dt

# opening ofx file
with open('/home/jovani/Downloads/ofx.ofx') as file:
    # Parser
    ofx = OfxParser.parse(file)
    #finding transactions
    transactions = ofx.account.statement.transactions
    now = dt.now() # I'll use this id like
    for fitid in transactions: #performing changes and it happens
        fitid_before = fitid.id
        fitid_after = now.strftime("%Y%m%d%f")
        fitid = fitid_after

Afterward, nothing was changed in ofx.ofx file.

1

There are 1 best solutions below

0
On

You are asking why the file was not changed.

  1. You opened the file for read-only. That is the default with "with open".
  2. You did not attempt to write anything to the file.