Sun, 01 Apr 2012 01:56:09 +0100
Fix handling of quoted CSV fields, allowing this year's CSV to be properly parsed
0 | 1 | local http = require "socket.http" |
2 | local have_https, https = pcall(require,"https"); | |
3 | local csv = require "csv" | |
4 | ||
2
5c9d6eba65bc
parse.lua: Update for gsoc12.csv, and *hack* the code to work with the new format
Matthew Wild <mwild1@gmail.com>
parents:
0
diff
changeset
|
5 | for line in io.lines(arg[1] or "gsoc12.csv") do |
0 | 6 | local project = {}; |
7 | csv.read_record(line, function (v) project[#project+1] = v; end); | |
3
5b24d66365ec
Fix handling of quoted CSV fields, allowing this year's CSV to be properly parsed
Matthew Wild <mwild1@gmail.com>
parents:
2
diff
changeset
|
8 | local url = project[5] and project[5]:match("https?://[^\"]+"); |
0 | 9 | if url and url:match("^http"..(have_https and "s?" or "")..":") then |
10 | local data, err = http.request(url); | |
11 | if not data then | |
12 | print("[FAIL] "..project[2]..": "..tostring(err)); | |
13 | elseif data:match("[%W%p][Ll][Uu][Aa][%W%p]") then | |
14 | print(project[2]..": "..url); | |
15 | end | |
16 | elseif project[2] ~= "Name" then | |
17 | print("[FAIL] "..project[2]..": Couldn't fetch URL ("..(url or "couldn't find one")..")"); | |
18 | end | |
19 | end |