{"action":"created","comment":{"url":"https://api.github.com/repos/frictionlessdata/goodtables/pulls/comments/63824954","id":63824954,"diff_hunk":"@@ -30,22 +31,22 @@\n     basestring = basestring\n     numeric_types = (int, long, float)\n \n-    def csv_reader(data, dialect=csv.excel, **kwargs):\n+    def csv_reader(data, dialect=csv.excel, header_index=0, **kwargs):\n         \"\"\"Read text stream (unicode on Py2.7) as CSV.\"\"\"\n \n-        first_lines = list(islice(data, 5))\n-        try:\n-            dialect = csv.Sniffer().sniff(''.join(first_lines))\n-            dialect.delimiter = dialect.delimiter.encode('utf-8')\n-            dialect.quotechar = dialect.quotechar.encode('utf-8')\n-        except csv.Error:\n-            dialect = csv.excel\n-\n+        first_lines = list(islice(data, header_index, header_index + 2))\n+        dialect = detect_dialect(first_lines)\n+        \n+        while not re.findall('[^\\w ]', dialect.delimiter): ","path":"goodtables/compat.py","position":29,"original_position":29,"commit_id":"06666e3ef3514d61267bf367333ab43c8f010f51","original_commit_id":"06666e3ef3514d61267bf367333ab43c8f010f51","user":{"login":"akariv","id":265333,"avatar_url":"https://avatars.githubusercontent.com/u/265333?v=3","gravatar_id":"","url":"https://api.github.com/users/akariv","html_url":"https://github.com/akariv","followers_url":"https://api.github.com/users/akariv/followers","following_url":"https://api.github.com/users/akariv/following{/other_user}","gists_url":"https://api.github.com/users/akariv/gists{/gist_id}","starred_url":"https://api.github.com/users/akariv/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/akariv/subscriptions","organizations_url":"https://api.github.com/users/akariv/orgs","repos_url":"https://api.github.com/users/akariv/repos","events_url":"https://api.github.com/users/akariv/events{/privacy}","received_events_url":"https://api.github.com/users/akariv/received_events","type":"User","site_admin":false},"body":"better to use [`isspace`](https://docs.python.org/2/library/stdtypes.html#str.isspace) for this, no?","created_at":"2016-05-19T05:42:09Z","updated_at":"2016-05-19T05:42:09Z","html_url":"https://github.com/frictionlessdata/goodtables/pull/104#discussion_r63824954","pull_request_url":"https://api.github.com/repos/frictionlessdata/goodtables/pulls/104","_links":{"self":{"href":"https://api.github.com/repos/frictionlessdata/goodtables/pulls/comments/63824954"},"html":{"href":"https://github.com/frictionlessdata/goodtables/pull/104#discussion_r63824954"},"pull_request":{"href":"https://api.github.com/repos/frictionlessdata/goodtables/pulls/104"}}},"pull_request":{"url":"https://api.github.com/repos/frictionlessdata/goodtables/pulls/104","id":70619519,"html_url":"https://github.com/frictionlessdata/goodtables/pull/104","diff_url":"https://github.com/frictionlessdata/goodtables/pull/104.diff","patch_url":"https://github.com/frictionlessdata/goodtables/pull/104.patch","issue_url":"https://api.github.com/repos/frictionlessdata/goodtables/issues/104","number":104,"state":"open","locked":false,"title":"Improve CSV dialect detection","user":{"login":"georgiana-b","id":8862002,"avatar_url":"https://avatars.githubusercontent.com/u/8862002?v=3","gravatar_id":"","url":"https://api.github.com/users/georgiana-b","html_url":"https://github.com/georgiana-b","followers_url":"https://api.github.com/users/georgiana-b/followers","following_url":"https://api.github.com/users/georgiana-b/following{/other_user}","gists_url":"https://api.github.com/users/georgiana-b/gists{/gist_id}","starred_url":"https://api.github.com/users/georgiana-b/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/georgiana-b/subscriptions","organizations_url":"https://api.github.com/users/georgiana-b/orgs","repos_url":"https://api.github.com/users/georgiana-b/repos","events_url":"https://api.github.com/users/georgiana-b/events{/privacy}","received_events_url":"https://api.github.com/users/georgiana-b/received_events","type":"User","site_admin":false},"body":"Should solve: #100, #98.\r\nSince the CSV dialect detection is statistical, having a fixed value isn't suitable for all cases and the detection fails for very short or very long files.\r\nThis implementation starts sampling from 2 rows and continues to add until it finds a delimiter that is not (entirely) alaphanumeric or space. It is also the lightest I could come up with. If you have a better idea, please share. ","created_at":"2016-05-19T00:10:47Z","updated_at":"2016-05-19T05:42:09Z","closed_at":null,"merged_at":null,"merge_commit_sha":"7fbde8cf55d1448309bab710151d6caed7a6ebb0","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/frictionlessdata/goodtables/pulls/104/commits","review_comments_url":"https://api.github.com/repos/frictionlessdata/goodtables/pulls/104/comments","review_comment_url":"https://api.github.com/repos/frictionlessdata/goodtables/pulls/comments{/number}","comments_url":"https://api.github.com/repos/frictionlessdata/goodtables/issues/104/comments","statuses_url":"https://api.github.com/repos/frictionlessdata/goodtables/statuses/06666e3ef3514d61267bf367333ab43c8f010f51","head":{"label":"frictionlessdata:hotfix/improve_csv_detection","ref":"hotfix/improve_csv_detection","sha":"06666e3ef3514d61267bf367333ab43c8f010f51","user":{"login":"frictionlessdata","id":5912125,"avatar_url":"https://avatars.githubusercontent.com/u/5912125?v=3","gravatar_id":"","url":"https://api.github.com/users/frictionlessdata","html_url":"https://github.com/frictionlessdata","followers_url":"https://api.github.com/users/frictionlessdata/followers","following_url":"https://api.github.com/users/frictionlessdata/following{/other_user}","gists_url":"https://api.github.com/users/frictionlessdata/gists{/gist_id}","starred_url":"https://api.github.com/users/frictionlessdata/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/frictionlessdata/subscriptions","organizations_url":"https://api.github.com/users/frictionlessdata/orgs","repos_url":"https://api.github.com/users/frictionlessdata/repos","events_url":"https://api.github.com/users/frictionlessdata/events{/privacy}","received_events_url":"https://api.github.com/users/frictionlessdata/received_events","type":"Organization","site_admin":false},"repo":{"id":28409905,"name":"goodtables","full_name":"frictionlessdata/goodtables","owner":{"login":"frictionlessdata","id":5912125,"avatar_url":"https://avatars.githubusercontent.com/u/5912125?v=3","gravatar_id":"","url":"https://api.github.com/users/frictionlessdata","html_url":"https://github.com/frictionlessdata","followers_url":"https://api.github.com/users/frictionlessdata/followers","following_url":"https://api.github.com/users/frictionlessdata/following{/other_user}","gists_url":"https://api.github.com/users/frictionlessdata/gists{/gist_id}","starred_url":"https://api.github.com/users/frictionlessdata/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/frictionlessdata/subscriptions","organizations_url":"https://api.github.com/users/frictionlessdata/orgs","repos_url":"https://api.github.com/users/frictionlessdata/repos","events_url":"https://api.github.com/users/frictionlessdata/events{/privacy}","received_events_url":"https://api.github.com/users/frictionlessdata/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/frictionlessdata/goodtables","description":"Validate and process tabular data.","fork":false,"url":"https://api.github.com/repos/frictionlessdata/goodtables","forks_url":"https://api.github.com/repos/frictionlessdata/goodtables/forks","keys_url":"https://api.github.com/repos/frictionlessdata/goodtables/keys{/key_id}","collaborators_url":"https://api.github.com/repos/frictionlessdata/goodtables/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/frictionlessdata/goodtables/teams","hooks_url":"https://api.github.com/repos/frictionlessdata/goodtables/hooks","issue_events_url":"https://api.github.com/repos/frictionlessdata/goodtables/issues/events{/number}","events_url":"https://api.github.com/repos/frictionlessdata/goodtables/events","assignees_url":"https://api.github.com/repos/frictionlessdata/goodtables/assignees{/user}","branches_url":"https://api.github.com/repos/frictionlessdata/goodtables/branches{/branch}","tags_url":"https://api.github.com/repos/frictionlessdata/goodtables/tags","blobs_url":"https://api.github.com/repos/frictionlessdata/goodtables/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/frictionlessdata/goodtables/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/frictionlessdata/goodtables/git/refs{/sha}","trees_url":"https://api.github.com/repos/frictionlessdata/goodtables/git/trees{/sha}","statuses_url":"https://api.github.com/repos/frictionlessdata/goodtables/statuses/{sha}","languages_url":"https://api.github.com/repos/frictionlessdata/goodtables/languages","stargazers_url":"https://api.github.com/repos/frictionlessdata/goodtables/stargazers","contributors_url":"https://api.github.com/repos/frictionlessdata/goodtables/contributors","subscribers_url":"https://api.github.com/repos/frictionlessdata/goodtables/subscribers","subscription_url":"https://api.github.com/repos/frictionlessdata/goodtables/subscription","commits_url":"https://api.github.com/repos/frictionlessdata/goodtables/commits{/sha}","git_commits_url":"https://api.github.com/repos/frictionlessdata/goodtables/git/commits{/sha}","comments_url":"https://api.github.com/repos/frictionlessdata/goodtables/comments{/number}","issue_comment_url":"https://api.github.com/repos/frictionlessdata/goodtables/issues/comments{/number}","contents_url":"https://api.github.com/repos/frictionlessdata/goodtables/contents/{+path}","compare_url":"https://api.github.com/repos/frictionlessdata/goodtables/compare/{base}...{head}","merges_url":"https://api.github.com/repos/frictionlessdata/goodtables/merges","archive_url":"https://api.github.com/repos/frictionlessdata/goodtables/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/frictionlessdata/goodtables/downloads","issues_url":"https://api.github.com/repos/frictionlessdata/goodtables/issues{/number}","pulls_url":"https://api.github.com/repos/frictionlessdata/goodtables/pulls{/number}","milestones_url":"https://api.github.com/repos/frictionlessdata/goodtables/milestones{/number}","notifications_url":"https://api.github.com/repos/frictionlessdata/goodtables/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/frictionlessdata/goodtables/labels{/name}","releases_url":"https://api.github.com/repos/frictionlessdata/goodtables/releases{/id}","deployments_url":"https://api.github.com/repos/frictionlessdata/goodtables/deployments","created_at":"2014-12-23T17:11:11Z","updated_at":"2016-04-16T15:53:37Z","pushed_at":"2016-05-19T05:24:45Z","git_url":"git://github.com/frictionlessdata/goodtables.git","ssh_url":"git@github.com:frictionlessdata/goodtables.git","clone_url":"https://github.com/frictionlessdata/goodtables.git","svn_url":"https://github.com/frictionlessdata/goodtables","homepage":"http://goodtables.readthedocs.org/","size":795,"stargazers_count":33,"watchers_count":33,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":9,"mirror_url":null,"open_issues_count":16,"forks":9,"open_issues":16,"watchers":33,"default_branch":"master"}},"base":{"label":"frictionlessdata:master","ref":"master","sha":"f620ecf8c67b3ba8a7f4a47ab93aa7db1e0b7b2e","user":{"login":"frictionlessdata","id":5912125,"avatar_url":"https://avatars.githubusercontent.com/u/5912125?v=3","gravatar_id":"","url":"https://api.github.com/users/frictionlessdata","html_url":"https://github.com/frictionlessdata","followers_url":"https://api.github.com/users/frictionlessdata/followers","following_url":"https://api.github.com/users/frictionlessdata/following{/other_user}","gists_url":"https://api.github.com/users/frictionlessdata/gists{/gist_id}","starred_url":"https://api.github.com/users/frictionlessdata/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/frictionlessdata/subscriptions","organizations_url":"https://api.github.com/users/frictionlessdata/orgs","repos_url":"https://api.github.com/users/frictionlessdata/repos","events_url":"https://api.github.com/users/frictionlessdata/events{/privacy}","received_events_url":"https://api.github.com/users/frictionlessdata/received_events","type":"Organization","site_admin":false},"repo":{"id":28409905,"name":"goodtables","full_name":"frictionlessdata/goodtables","owner":{"login":"frictionlessdata","id":5912125,"avatar_url":"https://avatars.githubusercontent.com/u/5912125?v=3","gravatar_id":"","url":"https://api.github.com/users/frictionlessdata","html_url":"https://github.com/frictionlessdata","followers_url":"https://api.github.com/users/frictionlessdata/followers","following_url":"https://api.github.com/users/frictionlessdata/following{/other_user}","gists_url":"https://api.github.com/users/frictionlessdata/gists{/gist_id}","starred_url":"https://api.github.com/users/frictionlessdata/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/frictionlessdata/subscriptions","organizations_url":"https://api.github.com/users/frictionlessdata/orgs","repos_url":"https://api.github.com/users/frictionlessdata/repos","events_url":"https://api.github.com/users/frictionlessdata/events{/privacy}","received_events_url":"https://api.github.com/users/frictionlessdata/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/frictionlessdata/goodtables","description":"Validate and process tabular data.","fork":false,"url":"https://api.github.com/repos/frictionlessdata/goodtables","forks_url":"https://api.github.com/repos/frictionlessdata/goodtables/forks","keys_url":"https://api.github.com/repos/frictionlessdata/goodtables/keys{/key_id}","collaborators_url":"https://api.github.com/repos/frictionlessdata/goodtables/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/frictionlessdata/goodtables/teams","hooks_url":"https://api.github.com/repos/frictionlessdata/goodtables/hooks","issue_events_url":"https://api.github.com/repos/frictionlessdata/goodtables/issues/events{/number}","events_url":"https://api.github.com/repos/frictionlessdata/goodtables/events","assignees_url":"https://api.github.com/repos/frictionlessdata/goodtables/assignees{/user}","branches_url":"https://api.github.com/repos/frictionlessdata/goodtables/branches{/branch}","tags_url":"https://api.github.com/repos/frictionlessdata/goodtables/tags","blobs_url":"https://api.github.com/repos/frictionlessdata/goodtables/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/frictionlessdata/goodtables/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/frictionlessdata/goodtables/git/refs{/sha}","trees_url":"https://api.github.com/repos/frictionlessdata/goodtables/git/trees{/sha}","statuses_url":"https://api.github.com/repos/frictionlessdata/goodtables/statuses/{sha}","languages_url":"https://api.github.com/repos/frictionlessdata/goodtables/languages","stargazers_url":"https://api.github.com/repos/frictionlessdata/goodtables/stargazers","contributors_url":"https://api.github.com/repos/frictionlessdata/goodtables/contributors","subscribers_url":"https://api.github.com/repos/frictionlessdata/goodtables/subscribers","subscription_url":"https://api.github.com/repos/frictionlessdata/goodtables/subscription","commits_url":"https://api.github.com/repos/frictionlessdata/goodtables/commits{/sha}","git_commits_url":"https://api.github.com/repos/frictionlessdata/goodtables/git/commits{/sha}","comments_url":"https://api.github.com/repos/frictionlessdata/goodtables/comments{/number}","issue_comment_url":"https://api.github.com/repos/frictionlessdata/goodtables/issues/comments{/number}","contents_url":"https://api.github.com/repos/frictionlessdata/goodtables/contents/{+path}","compare_url":"https://api.github.com/repos/frictionlessdata/goodtables/compare/{base}...{head}","merges_url":"https://api.github.com/repos/frictionlessdata/goodtables/merges","archive_url":"https://api.github.com/repos/frictionlessdata/goodtables/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/frictionlessdata/goodtables/downloads","issues_url":"https://api.github.com/repos/frictionlessdata/goodtables/issues{/number}","pulls_url":"https://api.github.com/repos/frictionlessdata/goodtables/pulls{/number}","milestones_url":"https://api.github.com/repos/frictionlessdata/goodtables/milestones{/number}","notifications_url":"https://api.github.com/repos/frictionlessdata/goodtables/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/frictionlessdata/goodtables/labels{/name}","releases_url":"https://api.github.com/repos/frictionlessdata/goodtables/releases{/id}","deployments_url":"https://api.github.com/repos/frictionlessdata/goodtables/deployments","created_at":"2014-12-23T17:11:11Z","updated_at":"2016-04-16T15:53:37Z","pushed_at":"2016-05-19T05:24:45Z","git_url":"git://github.com/frictionlessdata/goodtables.git","ssh_url":"git@github.com:frictionlessdata/goodtables.git","clone_url":"https://github.com/frictionlessdata/goodtables.git","svn_url":"https://github.com/frictionlessdata/goodtables","homepage":"http://goodtables.readthedocs.org/","size":795,"stargazers_count":33,"watchers_count":33,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":9,"mirror_url":null,"open_issues_count":16,"forks":9,"open_issues":16,"watchers":33,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/frictionlessdata/goodtables/pulls/104"},"html":{"href":"https://github.com/frictionlessdata/goodtables/pull/104"},"issue":{"href":"https://api.github.com/repos/frictionlessdata/goodtables/issues/104"},"comments":{"href":"https://api.github.com/repos/frictionlessdata/goodtables/issues/104/comments"},"review_comments":{"href":"https://api.github.com/repos/frictionlessdata/goodtables/pulls/104/comments"},"review_comment":{"href":"https://api.github.com/repos/frictionlessdata/goodtables/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/frictionlessdata/goodtables/pulls/104/commits"},"statuses":{"href":"https://api.github.com/repos/frictionlessdata/goodtables/statuses/06666e3ef3514d61267bf367333ab43c8f010f51"}}}}