diff --git a/processor/luahelper-test.lua b/processor/luahelper-test.lua index 9bb12cf..f51f970 100644 --- a/processor/luahelper-test.lua +++ b/processor/luahelper-test.lua @@ -515,9 +515,9 @@ phoenix_brigade 30 0.1 shielding_basic battle_physicist_basic reinforced_battery assert(rows2[1].Health == rows[1].Health, "Round trip first row Health should match") -- Verify headers are preserved - assert(rows2[1].Headers ~= nil, "Round trip rows should have Headers field") - assert(#rows2[1].Headers == #rows[1].Headers, "Headers should have same number of elements") - assert(rows2[1].Headers[1] == rows[1].Headers[1], "First header should match") + assert(rows2.Headers ~= nil, "Round trip rows should have Headers field") + assert(#rows2.Headers == #rows.Headers, "Headers should have same number of elements") + assert(rows2.Headers[1] == rows.Headers[1], "First header should match") end) print("\nAll tests completed!") diff --git a/processor/luahelper.lua b/processor/luahelper.lua index 412bf6e..1e2f260 100644 --- a/processor/luahelper.lua +++ b/processor/luahelper.lua @@ -220,9 +220,9 @@ function fromCSV(csv, options) row[headerName] = dataRow[j] end end - row.Headers = headers table.insert(rows, row) end + rows.Headers = headers return rows, nil end @@ -255,9 +255,9 @@ function toCSV(rows, options) local rowStrings = {} -- Include headers row if requested and available - if includeHeaders and #rows > 0 and rows[1].Headers ~= nil then + if includeHeaders and #rows > 0 and rows.Headers ~= nil then local headerStrings = {} - for _, header in ipairs(rows[1].Headers) do + for _, header in ipairs(rows.Headers) do local headerStr = tostring(header) local needsQuoting = false if