{
  "id": "data/csv-quote-escape-mismatch",
  "signature": "CSV parsing error: quote character mismatch — expected '\"' but found ''",
  "signature_zh": "CSV解析错误：引号字符不匹配 — 期望 '\"' 但找到 ''",
  "regex": "CSV.*quote.*mismatch.*expected.*but found",
  "domain": "data",
  "category": "encoding_error",
  "subcategory": null,
  "root_cause": "CSV file uses single quotes for quoting fields but parser expects double quotes, or vice versa, often due to locale or export settings.",
  "root_cause_type": "generic",
  "root_cause_zh": "CSV文件使用单引号引用字段，但解析器期望双引号，反之亦然，通常由于区域设置或导出设置导致。",
  "versions": [
    {
      "version": "python 3.12",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "pandas 2.2.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "apache-commons-csv 1.10.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "Manually replacing all single quotes with double quotes in the CSV file using sed",
      "why_fails": "This can corrupt data if single quotes are part of the field content (e.g., names like O'Brien).",
      "fail_rate": 0.6,
      "condition": "",
      "sources": []
    },
    {
      "action": "Ignoring the error and proceeding with partially parsed data",
      "why_fails": "Results in misaligned columns and corrupt data; downstream processes will fail or produce wrong results.",
      "fail_rate": 0.95,
      "condition": "",
      "sources": []
    },
    {
      "action": "Specifying quote character in parser but using the wrong escape character",
      "why_fails": "If the escape character is also wrong (e.g., backslash vs doubling), parsing will still fail on embedded quotes.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Specify the correct quote character in pandas: `pd.read_csv('file.csv', quotechar=\"'\")` if the file uses single quotes.",
      "success_rate": 0.9,
      "how": "Specify the correct quote character in pandas: `pd.read_csv('file.csv', quotechar=\"'\")` if the file uses single quotes.",
      "condition": "",
      "sources": []
    },
    {
      "action": "Use the `escapechar` parameter if quotes are escaped with backslash: `pd.read_csv('file.csv', escapechar='\\\\')`.",
      "success_rate": 0.85,
      "how": "Use the `escapechar` parameter if quotes are escaped with backslash: `pd.read_csv('file.csv', escapechar='\\\\')`.",
      "condition": "",
      "sources": []
    },
    {
      "action": "Preprocess the file with a Python script to normalize quotes: `import csv; with open('input.csv', 'r') as f, open('output.csv', 'w', newline='') as out: reader = csv.reader(f, quotechar=\"'\"); writer = csv.writer(out, quotechar='\"'); writer.writerows(reader)`",
      "success_rate": 0.95,
      "how": "Preprocess the file with a Python script to normalize quotes: `import csv; with open('input.csv', 'r') as f, open('output.csv', 'w', newline='') as out: reader = csv.reader(f, quotechar=\"'\"); writer = csv.writer(out, quotechar='\"'); writer.writerows(reader)`",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "Specify the correct quote character in pandas: `pd.read_csv('file.csv', quotechar=\"'\")` if the file uses single quotes.",
    "Use the `escapechar` parameter if quotes are escaped with backslash: `pd.read_csv('file.csv', escapechar='\\\\')`.",
    "Preprocess the file with a Python script to normalize quotes: `import csv; with open('input.csv', 'r') as f, open('output.csv', 'w', newline='') as out: reader = csv.reader(f, quotechar=\"'\"); writer = csv.writer(out, quotechar='\"'); writer.writerows(reader)`"
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://pandas.pydata.org/docs/reference/api/pandas.read_csv.html",
  "official_doc_section": null,
  "error_code": "CSVParseException",
  "verification_tier": "ai_generated",
  "confidence": 0.88,
  "fix_success_rate": 0.9,
  "resolvable": "true",
  "first_seen": "2024-01-20",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}