{
  "id": 2670,
  "title": "indiv2012.csv contains a \\A0",
  "url": "/competitions/cir-prospect/discussion/2670",
  "author_name": "",
  "post_date": "2012-09-15T15:56:56.947Z",
  "votes": null,
  "comment_count": 8,
  "views": 4593,
  "content": "<p>While reading this in with python 3.2, either csv.reader or open, I got a <strong>\r\ncannot decode utf-8</strong>. No big deal, i've seen those before. But because the file is rather large I had to split this in linux using<strong>&nbsp;split -l 100000 indiv2012.csv indiv2012_split\r\n</strong>to figure out where the problem was.&nbsp;</p>\r\n<p>nicarid 1386221, there appears this control character(?)&nbsp;<strong>\\xa0&nbsp;</strong>inbetween &nbsp;&quot;SANSBERRY DICKMAN FREEMON &amp; &quot; in&nbsp;<strong>indiv2012.csv&nbsp;</strong>and a few more times in the rest of the file.</p>\r\n<p>My question is did anyone else have problems with this, reading this as ISO-8859-15 seems ok.</p>\r\n<p><strong><br>\r\n</strong></p>",
  "messages": [
    {
      "id": "14351",
      "postDate": "09/15/2012 15:56:56",
      "content": "<p>While reading this in with python 3.2, either csv.reader or open, I got a <strong>\r\ncannot decode utf-8</strong>. No big deal, i've seen those before. But because the file is rather large I had to split this in linux using<strong>&nbsp;split -l 100000 indiv2012.csv indiv2012_split\r\n</strong>to figure out where the problem was.&nbsp;</p>\r\n<p>nicarid 1386221, there appears this control character(?)&nbsp;<strong>\\xa0&nbsp;</strong>inbetween &nbsp;&quot;SANSBERRY DICKMAN FREEMON &amp; &quot; in&nbsp;<strong>indiv2012.csv&nbsp;</strong>and a few more times in the rest of the file.</p>\r\n<p>My question is did anyone else have problems with this, reading this as ISO-8859-15 seems ok.</p>\r\n<p><strong><br>\r\n</strong></p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "14599",
      "postDate": "09/19/2012 20:07:53",
      "content": "<pre>&nbsp;</pre>\r\n<pre>[code]</pre>\r\n<pre>import os<br>import csv<br>import json<br><br>filename = 'indiv2012.csv'<br><br>dict_states = {}<br><br>&quot;&quot;&quot; STEP 1, find sum donations per state &quot;&quot;&quot;<br><br>if False:<br>    def open_csv_test(filename):<br>        csvfile = open(filename, 'r', encoding='ISO-8859-15', newline='')<br>        ofile = csv.reader(csvfile, delimiter=',')<br><br>        ofile.__next__()<br>        for row in ofile:<br>            try:<br>                current_val = dict_states.get(row[11], 0.0)<br>                dict_states[row[11]] = float(row[17]) &#43; current_val<br>            except:<br>                print(row)<br><br>        with open('sum_per_state.json', 'w') as wfile:<br>            wfile.write(json.dumps(dict_states, sort_keys=True, indent=4))<br><br>    open_csv_test(filename)</pre>\r\n<pre>[/code]</pre>\r\n<pre>i'm wondering if this is a reasonable way to swathe through the content.</pre>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "14752",
      "postDate": "09/24/2012 17:28:26",
      "content": "<p>A better formatted file would definitely be useful; I attempted to work with this in mysql but after receiving a multitude of data truncation errors I moved to python. Continue receiving extra columns where unintended (I'm assuming due to the control character\r\n you mentioned above) The majority of my errors were 27 columns instead of 26, with the occasional 28.</p>\r\n<p>May I ask how you rectified the extra control character? </p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "14760",
      "postDate": "09/24/2012 20:55:46",
      "content": "<p>Hi guys -- I'll take a closer look at the file formatting and see if we can't get you something cleaner. More soon.</p>\r\n<p>Best,<br>\r\nChase</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "14868",
      "postDate": "09/27/2012 06:14:46",
      "content": "<p>Hi,</p>\r\n<p>Is it possible for you to upload a cleaned file or should we go ahead and try to clean it up ourselves?</p>\r\n<p>&nbsp;</p>\r\n<p>Thanks,</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "14874",
      "postDate": "09/27/2012 15:30:03",
      "content": "<p>Best I can do for now is this MySQL dump that imported cleanly when I tested it about 10 minutes ago. I'll check with the actual data providers about the error in the CSVs.</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "14928",
      "postDate": "09/28/2012 17:53:40",
      "content": "<p>The data attached in the above comment is new ? and clean ?</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "14939",
      "postDate": "09/28/2012 21:06:30",
      "content": "<p>It's a SQL dump of basically the same data as the CSV. I sure think it's clean, because I've imported it myself with no troubles.</p>\r\n<p>The data is also slightly more up-to-date (to the tune of a few weeks), but that doesn't really matter for the purposes of this competition.</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "14994",
      "postDate": "10/01/2012 14:00:28",
      "content": "<p>My apologies for lack of response here, lack of spare time has been monstrous. The script posted is the last thing i did (and some d3js mapping).</p>",
      "rawMarkdown": "",
      "votes": null
    }
  ],
  "comments": [
    {
      "id": 14599,
      "author_name": "dealga",
      "author_url": "",
      "post_date": "09/19/2012 20:07:53",
      "content": "<pre>&nbsp;</pre>\r\n<pre>[code]</pre>\r\n<pre>import os<br>import csv<br>import json<br><br>filename = 'indiv2012.csv'<br><br>dict_states = {}<br><br>&quot;&quot;&quot; STEP 1, find sum donations per state &quot;&quot;&quot;<br><br>if False:<br>    def open_csv_test(filename):<br>        csvfile = open(filename, 'r', encoding='ISO-8859-15', newline='')<br>        ofile = csv.reader(csvfile, delimiter=',')<br><br>        ofile.__next__()<br>        for row in ofile:<br>            try:<br>                current_val = dict_states.get(row[11], 0.0)<br>                dict_states[row[11]] = float(row[17]) &#43; current_val<br>            except:<br>                print(row)<br><br>        with open('sum_per_state.json', 'w') as wfile:<br>            wfile.write(json.dumps(dict_states, sort_keys=True, indent=4))<br><br>    open_csv_test(filename)</pre>\r\n<pre>[/code]</pre>\r\n<pre>i'm wondering if this is a reasonable way to swathe through the content.</pre>",
      "votes": null,
      "replies": []
    },
    {
      "id": 14752,
      "author_name": "joofeloof",
      "author_url": "",
      "post_date": "09/24/2012 17:28:26",
      "content": "<p>A better formatted file would definitely be useful; I attempted to work with this in mysql but after receiving a multitude of data truncation errors I moved to python. Continue receiving extra columns where unintended (I'm assuming due to the control character\r\n you mentioned above) The majority of my errors were 27 columns instead of 26, with the occasional 28.</p>\r\n<p>May I ask how you rectified the extra control character? </p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 14760,
      "author_name": "cjdd3b",
      "author_url": "",
      "post_date": "09/24/2012 20:55:46",
      "content": "<p>Hi guys -- I'll take a closer look at the file formatting and see if we can't get you something cleaner. More soon.</p>\r\n<p>Best,<br>\r\nChase</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 14868,
      "author_name": "hutokshisethna",
      "author_url": "",
      "post_date": "09/27/2012 06:14:46",
      "content": "<p>Hi,</p>\r\n<p>Is it possible for you to upload a cleaned file or should we go ahead and try to clean it up ourselves?</p>\r\n<p>&nbsp;</p>\r\n<p>Thanks,</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 14874,
      "author_name": "cjdd3b",
      "author_url": "",
      "post_date": "09/27/2012 15:30:03",
      "content": "<p>Best I can do for now is this MySQL dump that imported cleanly when I tested it about 10 minutes ago. I'll check with the actual data providers about the error in the CSVs.</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 14928,
      "author_name": "theory",
      "author_url": "",
      "post_date": "09/28/2012 17:53:40",
      "content": "<p>The data attached in the above comment is new ? and clean ?</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 14939,
      "author_name": "cjdd3b",
      "author_url": "",
      "post_date": "09/28/2012 21:06:30",
      "content": "<p>It's a SQL dump of basically the same data as the CSV. I sure think it's clean, because I've imported it myself with no troubles.</p>\r\n<p>The data is also slightly more up-to-date (to the tune of a few weeks), but that doesn't really matter for the purposes of this competition.</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 14994,
      "author_name": "dealga",
      "author_url": "",
      "post_date": "10/01/2012 14:00:28",
      "content": "<p>My apologies for lack of response here, lack of spare time has been monstrous. The script posted is the last thing i did (and some d3js mapping).</p>",
      "votes": null,
      "replies": []
    }
  ],
  "raw_markdown_by_id": {
    "14351": "",
    "14599": "",
    "14752": "",
    "14760": "",
    "14868": "",
    "14874": "",
    "14928": "",
    "14939": "",
    "14994": ""
  },
  "source": "meta"
}