mirror of
https://github.com/geoffleyland/lua-csv.git
synced 2024-11-23 01:34:19 +00:00
ignore blank lines (I'm not sure this is a good thing *in* the file, but ignoring blank lines at the end is a good idea)
This commit is contained in:
parent
279ca0717d
commit
ac033b3075
@ -285,7 +285,9 @@ local function separated_values_iterator(file, parameters)
|
||||
elseif parameters.header and not header then
|
||||
header = fields
|
||||
else
|
||||
coroutine.yield(fields, starts)
|
||||
if fields[1] ~= "" or fields[2] then -- ignore blank lines
|
||||
coroutine.yield(fields, starts)
|
||||
end
|
||||
end
|
||||
field_count, fields, starts = 0, {}, {}
|
||||
end
|
||||
|
@ -50,6 +50,9 @@ apple:four,charlie:60]],
|
||||
apple = { name = "ALPHA", transform = string.lower },
|
||||
charlie = { transform = function(x) return tonumber(x) * 10 end }}})
|
||||
|
||||
test("../test-data/blank-line.csv", [[
|
||||
this,file,ends,with,a,blank,line]])
|
||||
|
||||
|
||||
if errors == 0 then
|
||||
io.stdout:write("Passed\n")
|
||||
|
1
test-data/blank-line.csv
Normal file
1
test-data/blank-line.csv
Normal file
@ -0,0 +1 @@
|
||||
this,file,ends,with,a,blank,line
|
|
Loading…
Reference in New Issue
Block a user