mirror of
https://github.com/geoffleyland/lua-csv.git
synced 2024-11-23 01:34:19 +00:00
if use() is passed a file, uses that. If it's passed nil as the buffer, it uses stdin
This commit is contained in:
parent
8db3740230
commit
3b28558461
@ -411,9 +411,17 @@ buffer_mt.__index = buffer_mt
|
||||
|
||||
|
||||
local function use(buffer, parameters)
|
||||
parameters = parameters or {}
|
||||
parameters.filename = parameters.filename or "<unknown>"
|
||||
parameters.column_map = parameters.columns and
|
||||
column_map:new(parameters.columns)
|
||||
|
||||
if not buffer then
|
||||
buffer = file_buffer:new(io.stdin)
|
||||
elseif io.type(buffer) == "file" then
|
||||
buffer = file_buffer:new(buffer)
|
||||
end
|
||||
|
||||
local f = { buffer = buffer, parameters = parameters }
|
||||
return setmetatable(f, buffer_mt)
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user