From 4311533445c52b9231a30c98f90836d72159f9e8 Mon Sep 17 00:00:00 2001 From: PhatPhuckDave Date: Sat, 15 Nov 2025 15:56:03 +0100 Subject: [PATCH] Lowercase the csv options --- processor/luahelper.lua | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/processor/luahelper.lua b/processor/luahelper.lua index 485666b..31817a5 100644 --- a/processor/luahelper.lua +++ b/processor/luahelper.lua @@ -50,8 +50,8 @@ end --- @class ParserOptions --- @field delimiter string? The field delimiter (default: ","). ---- @field hasHeaders boolean? If true, first non-comment row is treated as headers (default: false). ---- @field hasComments boolean? If true, lines starting with '#' are skipped (default: false). +--- @field hasheader boolean? If true, first non-comment row is treated as headers (default: false). +--- @field hascomments boolean? If true, lines starting with '#' are skipped (default: false). --- Parses CSV text into rows and fields using a minimal RFC 4180 state machine. --- @@ -74,8 +74,8 @@ end function fromCSV(csv, options) if options == nil then options = {} end local delimiter = options.delimiter or "," - local hasHeaders = options.hasHeaders or false - local hasComments = options.hasComments or false + local hasheader = options.hasheader or false + local hascomments = options.hascomments or false local allRows = {} local fields = {} @@ -104,7 +104,7 @@ function fromCSV(csv, options) table.insert(fields, table.concat(field)) field = {} local shouldAdd = true - if hasComments and #fields > 0 then + if hascomments and #fields > 0 then local firstField = fields[1] local trimmed = string.gsub(firstField, "^%s*(.-)%s*$", "%1") if string.sub(trimmed, 1, 1) == "#" then shouldAdd = false end @@ -142,7 +142,7 @@ function fromCSV(csv, options) table.insert(fields, table.concat(field)) field = {} local shouldAdd = true - if hasComments and #fields > 0 then + if hascomments and #fields > 0 then local firstField = fields[1] local trimmed = string.gsub(firstField, "^%s*(.-)%s*$", "%1") if string.sub(trimmed, 1, 1) == "#" then shouldAdd = false end @@ -165,7 +165,7 @@ function fromCSV(csv, options) if #field > 0 or #fields > 0 then table.insert(fields, table.concat(field)) local shouldAdd = true - if hasComments and #fields > 0 then + if hascomments and #fields > 0 then local firstField = fields[1] local trimmed = string.gsub(firstField, "^%s*(.-)%s*$", "%1") if string.sub(trimmed, 1, 1) == "#" then shouldAdd = false end @@ -173,12 +173,12 @@ function fromCSV(csv, options) if shouldAdd then table.insert(allRows, fields) end end - if hasHeaders and #allRows > 0 then + if hasheader and #allRows > 0 then local headers = allRows[1] local rows = {} - for i = 2, #allRows do + for ii = 2, #allRows do local row = {} - local dataRow = allRows[i] + local dataRow = allRows[ii] for j = 1, #dataRow do row[j] = dataRow[j] if headers[j] ~= nil and headers[j] ~= "" then row[headers[j]] = dataRow[j] end