{"action":"opened","issue":{"url":"https://api.github.com/repos/pydata/pandas/issues/14122","repository_url":"https://api.github.com/repos/pydata/pandas","labels_url":"https://api.github.com/repos/pydata/pandas/issues/14122/labels{/name}","comments_url":"https://api.github.com/repos/pydata/pandas/issues/14122/comments","events_url":"https://api.github.com/repos/pydata/pandas/issues/14122/events","html_url":"https://github.com/pydata/pandas/issues/14122","id":174158286,"number":14122,"title":"Saving CSV with backslashed-escaping is not idempotent. Some backslash-escaped characters treated like special characters, not data.","user":{"login":"deads","id":118388,"avatar_url":"https://avatars.githubusercontent.com/u/118388?v=3","gravatar_id":"","url":"https://api.github.com/users/deads","html_url":"https://github.com/deads","followers_url":"https://api.github.com/users/deads/followers","following_url":"https://api.github.com/users/deads/following{/other_user}","gists_url":"https://api.github.com/users/deads/gists{/gist_id}","starred_url":"https://api.github.com/users/deads/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/deads/subscriptions","organizations_url":"https://api.github.com/users/deads/orgs","repos_url":"https://api.github.com/users/deads/repos","events_url":"https://api.github.com/users/deads/events{/privacy}","received_events_url":"https://api.github.com/users/deads/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-08-31T00:35:58Z","updated_at":"2016-08-31T00:35:58Z","closed_at":null,"body":"@pdbaines and I noticed this bug.\r\n\r\nI want Pandas to write a CSV file so that all field data is backslash escaped if the character has a special interpretation (e.g. quotes or backslashes themselves). If a quote is backslashed, it is treated as field data, rather than a special character. This is not the behavior that I am seeing.\r\n\r\nConsider the following data frame:\r\n\r\n```\r\ndf = pd.DataFrame({\"text\": [\"\"\"Hello! Please \"help\" me. I cannot quote a csv.\\\\\"\"\"], \"zoo\": [\"1\"]})\r\ndf.to_csv(\"out.csv\", index=False, quoting=csv.QUOTE_NONNUMERIC, encoding=\"utf-8\", escapechar='\\\\', doublequote=False)\r\n```\r\n\r\nWhen written to a file, it looks something like this:\r\n\r\n```\r\n\"text\",\"zoo\"\r\n\"Hello! Please \\\"help\\\" me. I cannot quote a csv.\\\",\"1\"\r\n```\r\n\r\nThe quotes are properly escaped in `Please \"help\" me`, but oddly, the end-quote of the field is backslashed, but the start-quote of the field is not back-slashed.\r\n\r\nIf I read the data frame in again using exactly the same parameters,\r\n```\r\ndf2 = pd.read_csv(\"out.csv\", quoting=csv.QUOTE_NONNUMERIC, encoding=\"utf-8\", escapechar='\\\\', doublequote=False)\r\n```\r\n\r\nI get a data frame with both fields concatenated into the first field and the second field is NaN.\r\n\r\n```\r\n$ print df2\r\n                                                text  zoo\r\n0  Hello! Please \"help\" me. I cannot quote a csv....  NaN\r\n\r\n```\r\n\r\n\r\n#### output of ``pd.show_versions()``\r\n\r\n```\r\nINSTALLED VERSIONS\r\n------------------\r\ncommit: None\r\npython: 3.5.1.final.0\r\npython-bits: 64\r\nOS: Linux\r\nOS-release: 3.13.0-39-generic\r\nmachine: x86_64\r\nprocessor: x86_64\r\nbyteorder: little\r\nLC_ALL: None\r\nLANG: en_US.UTF-8\r\n\r\npandas: 0.18.0\r\nnose: 1.3.7\r\npip: 8.1.1\r\nsetuptools: 20.3\r\nCython: 0.23.4\r\nnumpy: 1.10.4\r\nscipy: 0.17.0\r\nstatsmodels: 0.6.1\r\nxarray: None\r\nIPython: 4.1.2\r\nsphinx: 1.3.5\r\npatsy: 0.4.0\r\ndateutil: 2.5.1\r\npytz: 2016.2\r\nblosc: None\r\nbottleneck: 1.0.0\r\ntables: 3.2.2\r\nnumexpr: 2.5\r\nmatplotlib: 1.5.1\r\nopenpyxl: 2.3.2\r\nxlrd: 0.9.4\r\nxlwt: 1.0.0\r\nxlsxwriter: 0.8.4\r\nlxml: 3.6.0\r\nbs4: 4.4.1\r\nhtml5lib: None\r\nhttplib2: None\r\napiclient: None\r\nsqlalchemy: 1.0.12\r\npymysql: None\r\npsycopg2: None\r\njinja2: 2.8\r\nboto: 2.39.0\r\n```"}}
{"actor":{"display_login":"deads"}}