{"id":4859,"library":"xlsx2csv","title":"xlsx2csv","description":"xlsx2csv is a Python library and command-line tool designed to convert XLSX files to CSV format. It is efficient, capable of handling large XLSX files, and fast. The current version is 0.8.6, and the project shows an active development and release cadence with recent updates addressing various bug fixes and Python version compatibility.","status":"active","version":"0.8.6","language":"en","source_language":"en","source_url":"http://github.com/dilshod/xlsx2csv","tags":["excel","csv","conversion","xlsx"],"install":[{"cmd":"pip install xlsx2csv","lang":"bash","label":"Install with pip"}],"dependencies":[],"imports":[{"symbol":"Xlsx2csv","correct":"from xlsx2csv import Xlsx2csv"}],"quickstart":{"code":"import os\nfrom xlsx2csv import Xlsx2csv\n\n# Create a dummy XLSX file for demonstration\n# In a real scenario, this file would already exist.\n# For simplicity, we'll just demonstrate the conversion logic.\n# You might use openpyxl to create a real .xlsx file for testing:\n# import openpyxl\n# wb = openpyxl.Workbook()\n# ws = wb.active\n# ws['A1'] = 'Header1'\n# ws['B1'] = 'Header2'\n# ws['A2'] = 'Data1'\n# ws['B2'] = 'Data2'\n# wb.save('example.xlsx')\n\n# Ensure a dummy file path exists for the example\nexcel_file = 'example.xlsx'\ncsv_output = 'example.csv'\n\n# To make this runnable without needing openpyxl just for quickstart:\n# Create a dummy excel_file (normally this would be a real .xlsx)\nwith open(excel_file, 'w') as f:\n    f.write('This is a placeholder for a .xlsx file content.')\n\n# Recommended: using context manager for proper resource cleanup\ntry:\n    with Xlsx2csv(excel_file, outputencoding=\"utf-8\") as converter:\n        converter.convert(csv_output)\n    print(f\"Successfully converted '{excel_file}' to '{csv_output}'.\")\n\n    # Optionally, read and print the CSV content to verify\n    if os.path.exists(csv_output):\n        with open(csv_output, 'r', encoding='utf-8') as f_csv:\n            print(\"CSV Content:\\n\" + f_csv.read())\n    else:\n        print(f\"Error: CSV file '{csv_output}' not created.\")\n\nexcept Exception as e:\n    print(f\"An error occurred during conversion: {e}\")\nfinally:\n    # Clean up dummy files\n    if os.path.exists(excel_file):\n        os.remove(excel_file)\n    if os.path.exists(csv_output):\n        os.remove(csv_output)\n","lang":"python","description":"This quickstart demonstrates how to convert an XLSX file to CSV using the `Xlsx2csv` class with a context manager for proper resource cleanup. It also includes basic error handling and cleanup of the dummy files for a self-contained example."},"warnings":[{"fix":"Update any error handling catching `zipfile.BadZipfile` to `zipfile.BadZipFile`.","message":"Prior to version 0.8.2, `xlsx2csv` might have used or re-raised `zipfile.BadZipfile`. With the update in version 0.8.2, `BadZipFile` (with a capital 'F') is used, aligning with deprecations in Python's `zipfile` module since Python 3.2.","severity":"breaking","affected_versions":"<0.8.2"},{"fix":"Upgrade to `xlsx2csv` version 0.8.3 or newer to ensure compatibility with Python 3.12+.","message":"Versions of `xlsx2csv` prior to 0.8.3 could encounter a `SyntaxError` when run on Python 3.12 or newer due to changes in how Python 3.12 handles invalid escape sequences in regular expressions.","severity":"breaking","affected_versions":"<0.8.3"},{"fix":"Always use `Xlsx2csv` with a `with` statement: `with Xlsx2csv('file.xlsx') as converter: converter.convert('file.csv')`.","message":"Not using `Xlsx2csv` within a `with` statement (context manager) may lead to `ResourceWarning` in modern Python versions due to improper resource cleanup.","severity":"gotcha","affected_versions":"All versions (if not using context manager)"},{"fix":"Upgrade to `xlsx2csv` version 0.8.3 or newer to resolve issues related to missing workbook relationships.","message":"In versions prior to 0.8.3, a bug existed when processing XLSX files with missing workbook relationships, which could lead to conversion failures or unexpected behavior.","severity":"gotcha","affected_versions":"<0.8.3"},{"fix":"Upgrade to `xlsx2csv` version 0.8.2 or newer to correctly handle XLSX files with hyperlinks.","message":"XLSX files containing hyperlinks could cause crashes or incorrect processing in `xlsx2csv` versions older than 0.8.2.","severity":"gotcha","affected_versions":"<0.8.2"}],"env_vars":null,"last_verified":"2026-04-12T00:00:00.000Z","next_check":"2026-07-11T00:00:00.000Z"}