print(f"Converted {csv_file} to {iif_file}") csv_to_iif("export.csv", "import.iif")
import csv def csv_to_iif(csv_file, iif_file): with open(csv_file, 'r', encoding='utf-8') as infile: reader = csv.DictReader(infile) rows = list(reader) how to convert csv to iif
A simple, universal format where each line represents a data record, and fields within a record are separated by commas. CSV files are widely supported by spreadsheet applications like Microsoft Excel, Google Sheets, and various database tools. They contain raw data but lack structural metadata about how that data should be interpreted by accounting software. "import.iif") import csv def csv_to_iif(csv_file
with open(iif_file, 'w', encoding='utf-8') as outfile: # Write IIF headers outfile.write("!TRNS\n") outfile.write("TRNSID,DATE,ACCNT,NAME,AMOUNT,DOCNUM,MEMO\n") # Write transaction lines for row in rows: line = f"{row['ID']},{row['Date']},{row['Account']},{row['Name']},{row['Amount']},{row['DocNum']},{row['Memo']}\n" outfile.write(line) iif_file): with open(csv_file