Skip to content

Commit

Permalink
Added option to toggle CSV header on and off.
Browse files Browse the repository at this point in the history
  • Loading branch information
CruelDrool committed Sep 6, 2023
1 parent ddbc29e commit 89263be
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 10 deletions.
33 changes: 23 additions & 10 deletions Core.lua
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ local defaults = {
depth = 4,
},
csv = {
header = true,
delimiter = ',',
enclosure = '"',
},
Expand Down Expand Up @@ -295,22 +296,31 @@ local options = {
name = supportedFileFormats["csv"],
-- guiInline = true,
args = {
delimiter = {
header = {
order = 1,
type = "toggle",
width = "full",
name = L["Header"] ,
desc = "",
get = function() return addon.db.profile.csv.header end,
set = function(info, value) addon.db.profile.csv.header = value end,
},
delimiter = {
order = 2,
type = "input",
width = "half",
name = L["Delimiter"],
get = function() return addon.db.profile.csv.delimiter end,
set = function(info, value) if value ~= "" then addon.db.profile.csv.delimiter = value end end,
},
spacer1 = {
order = 2,
order = 3,
width = "full",
type = "description",
name = "",
},
enclosure = {
order = 3,
order = 4,
type = "input",
width = "half",
name = L["Enclosure"],
Expand Down Expand Up @@ -856,19 +866,22 @@ end
function addon:csv(data)
local enclosure = self.db.profile.csv.enclosure
local delimiter = self.db.profile.csv.delimiter
local header = self.db.profile.csv.header
local columns = self.db.profile.columns
local output = ""
local header = {}
local headerData = {}

for _, v in ipairs(columns) do
if v.enabled then
table.insert(header, v.name)
if header then
for _, v in ipairs(columns) do
if v.enabled then
table.insert(headerData, v.name)
end
end
end

data[0] = header
data[0] = headerData
end

for i=0, #data do
for i=header and 0 or 1, #data do
local line = ""
for _, c in pairs(data[i]) do
if (type(c) == "string") then
Expand Down
1 change: 1 addition & 0 deletions Localization/enUS.lua
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ L["Set the depth used when spaces are set as indentation style. Smaller depth sh
L["Spaces are the default indentation style because tabs may be displayed as a strange symbol in the export window. However, copying the tabs work just fine and will be displayed correctly in a text editor."] = true

-- OPTIONS: Settings -> CSV --
L["Header"] = true
L["Delimiter"] = true
L["Enclosure"] = true

Expand Down

0 comments on commit 89263be

Please sign in to comment.