diff --git a/lua/csv.lua b/lua/csv.lua index a7dffc7..d01c7b1 100644 --- a/lua/csv.lua +++ b/lua/csv.lua @@ -150,13 +150,9 @@ end -- the buffer. local function separated_values_iterator(file, parameters) local buffer_size = parameters.buffer_size or DEFAULT_BUFFER_SIZE - local filename = parameters.filename or "" local buffer = "" local anchor_pos = 1 - local line, line_start = 1, 1 - local column_name_map = parameters.columns and - build_column_name_map(parameters.columns) - local column_index_map + local line_start = 1 -- Cut the front off the buffer if we've already read it @@ -208,6 +204,13 @@ local function separated_values_iterator(file, parameters) end + local filename = parameters.filename or "" + local line = 1 + local column_name_map = parameters.columns and + build_column_name_map(parameters.columns) + local column_index_map + + -- If the user hasn't specified a separator, try to work out what it is. local sep = parameters.separator if not sep then