{"id":5738,"library":"unicodecsv","title":"unicodecsv Library","description":"unicodecsv is a Python 2 library that provides a drop-in replacement for the standard library's `csv` module, adding robust Unicode support. The current version is 0.14.1, released in 2016. This library is effectively abandoned and is no longer maintained, primarily serving legacy Python 2 applications.","status":"abandoned","version":"0.14.1","language":"en","source_language":"en","source_url":"https://github.com/jdunck/python-unicodecsv","tags":["csv","unicode","python2","legacy","encoding","abandoned"],"install":[{"cmd":"pip install unicodecsv","lang":"bash","label":"Install with pip"}],"dependencies":[],"imports":[{"symbol":"csv","correct":"import unicodecsv as csv"},{"symbol":"reader","correct":"from unicodecsv import reader"},{"symbol":"writer","correct":"from unicodecsv import writer"}],"quickstart":{"code":"import unicodecsv as csv\nimport io\n\n# This example demonstrates unicodecsv in a Python 2-like environment.\n# In Python 3, the standard `csv` module handles unicode correctly.\n\n# Simulate a file-like object for writing (expecting bytes)\noutput_buffer = io.BytesIO()\nwriter = csv.writer(output_buffer, encoding='utf-8')\nwriter.writerow(['héllø', 'wørld', '😊'])\nwriter.writerow(['line 2', 'value 2', 'another'])\n\n# Get the byte content written to the buffer\ncsv_bytes = output_buffer.getvalue()\nprint(\"unicodecsv: Written CSV bytes (Python 2 style):\")\nprint(csv_bytes.decode('utf-8')) # Decode for printing in Python 3 console\n\n# Simulate a file-like object for reading\ninput_buffer = io.BytesIO(csv_bytes)\nreader = csv.reader(input_buffer, encoding='utf-8')\n\nprint(\"\\nunicodecsv: Read CSV rows (Python 2 style):\")\nfor row in reader:\n    print(row)\n\n# Expected output in a Python 2 environment would be lists of unicode strings.","lang":"python","description":"Demonstrates writing and reading Unicode data using `unicodecsv` with `io.BytesIO` to simulate file operations. This library is specifically designed for Python 2 to correctly handle Unicode CSV files."},"warnings":[{"fix":"For Python 3, use the standard library's `csv` module directly. It natively supports Unicode and is the correct approach for modern Python applications.","message":"unicodecsv is fundamentally incompatible with Python 3's `csv` module. Python 3's `csv` module expects text streams, not byte streams, and handles unicode automatically. Using `unicodecsv` in Python 3 will lead to `TypeError` or incorrect encoding behavior.","severity":"breaking","affected_versions":"All versions of unicodecsv when used with Python 3."},{"fix":"Migrate to Python 3 and use the built-in `csv` module for Unicode CSV handling.","message":"This library is effectively abandoned and unmaintained since its last release in 2016. Its primary purpose was to address Unicode issues in Python 2's standard `csv` module. Python 3's `csv` module resolved these issues natively, making this library obsolete for modern Python development.","severity":"deprecated","affected_versions":"All versions"},{"fix":"Do not install or use `unicodecsv` in Python 3 projects. Rely on the standard `csv` library instead.","message":"unicodecsv is designed *exclusively* for Python 2. Attempting to use it in a Python 3 environment is incorrect and will introduce unnecessary complexity and potential encoding errors. It adds no value in Python 3.","severity":"gotcha","affected_versions":"All versions when used with Python 3"},{"fix":"Always use binary mode (`'wb'`, `'rb'`) when opening files for `unicodecsv.writer` or `unicodecsv.reader` in Python 2.","message":"When using `unicodecsv` in Python 2, ensure files are opened in binary mode (e.g., `open('filename', 'wb')` or `open('filename', 'rb')`). The library expects byte streams for its internal encoding/decoding mechanism.","severity":"gotcha","affected_versions":"All versions when used with Python 2"}],"env_vars":null,"last_verified":"2026-04-09T00:00:00.000Z","next_check":"2026-07-08T00:00:00.000Z"}