{
  "id": 22132613,
  "title": "Hand bank data from Python to Excel as XLSX, not CSV, to keep references intact",
  "url": "https://urgent.news/2026/11/27/hand-bank-data-from-python-to-excel-as-xlsx-not-csv-to-keep",
  "topic": "tech",
  "section": "Tech",
  "published": "2026-11-27T08:00:00.000Z",
  "source": {
    "name": "Dev.to",
    "slug": "dev-to",
    "url": "https://dev.to/bankstatementscan/hand-bank-data-from-python-to-excel-as-xlsx-not-csv-to-keep-references-intact-243p"
  },
  "original_language": "en",
  "account": "When Python transfers bank transaction data to someone who uses Excel, save the file as an XLSX instead of a CSV. A CSV file does not preserve column types, causing Excel to misinterpret data, including leading zeros, long identifiers, and date formats. An XLSX file, however, retains each cell's type, ensuring proper handling of data cells.\n\nTo create the XLSX file, use openpyxl and load_workbook modules in Python. Define fictional transaction rows, including date, reference, description, and amount. Append the header row to the active worksheet, then iterate through the transaction rows, appending each row to the worksheet. Set the date format to yyyy-mm-dd, use \"@\" for the text format of the reference, and store the description as a string using data_type = \"s\".\n\nSave the workbook as \"handover.xlsx\". To verify the file, load it back into Python and iterate through the rows, printing the data type of each cell along with the actual values. This confirms that dates, strings, and numbers are correctly preserved in the XLSX file.\n\nWhen creating the XLSX file, ensure amounts are stored as Python Decimal values to avoid rounding issues. Dates should be written as real date objects, while the display format should be yyyy-mm-dd for unambiguous reading. Recheck totals by recomputing debits, credits, and closing balance after saving the file. Only use a CSV when the receiving system specifically requests it; in that case, add a short field note detailing the reference type, date format, decimal mark, and sign convention. Always test the CSV through the recipient's import route to ensure proper handling.",
  "summary": "If a Python pipeline hands bank transactions to someone who works in Excel, write an XLSX file rather than a CSV. A CSV carries no column types, so every person who double-clicks it lets Excel guess again: references lose leading zeros, 16-digit identifiers end in 0, dates can flip. An XLSX stores each cell's type, so you decide once, in code. Quoting fields in the CSV does not change this.…",
  "key_points": [
    "Save bank data as XLSX, not CSV, to preserve column types",
    "Use openpyxl and loadworkbook modules in Python",
    "Verify XLSX file by loading back into Python and checking cell data types"
  ],
  "editors_take": "Prioritizing XLSX over CSV during data handovers prevents Excel from corrupting critical banking identifiers and date formats, ensuring that financial records remain accurate and structurally intact for the recipient.",
  "illustration": null,
  "coverage": {
    "outlets": 1,
    "also_reported_by": []
  },
  "ai_generated": true,
  "disclaimer": "Summaries, key points and the editor’s take are written by software from other outlets’ reporting and may contain errors — always check the linked original."
}