Skip to content

API 文档 Csv

xerysherry edited this page Nov 7, 2019 · 1 revision

目录

说明

function SetCsvPath(path=["Csv"])

path: 字符串, Csv路径

设置Csv路径

function GetCsvPath()

返回Csv路径

function CsvDecode(name, haskey=false, dictflag=false)

name: 字符串, Csv文件名, 无需.csv后缀名 haskey: 布尔型, 是否包含列头 dictflag: 布尔型, 是否解码字典格式

Csv解码, 优先读取Resources/Csv/下文件

--[[
    Project Path/Csv/test.csv
content:
    a, b, c
    1, 2, 3
    4, 5, 6
    7, 8, 9
]]

SetCsvPath("Csv")
local t1 = CsvDecode("test") 
-- t1 = {{"a", "b", "c"},{"1", "2", "3"},{"4", "5", "6"},{"7", "8", "9"}}
local t2 = CsvDecode("test", true)
-- t2 = {{a="1", b="2", c="3"},{a="4", b="5", c="6"},{a="7", b="8", c="9"}}
local t3 = CsvDecode("test", true, true)
--[[ t2 = {
           ["1"]={a="1", b="2", c="3"}, 
           ["4"]={a="4", b="5", c="6"},
           ["7"]={a="7", b="8", c="9"},
        }]]

Clone this wiki locally