FourierTransformer / ftcsv

a fast csv library written in pure Lua
MIT License
73 stars 20 forks source link

Issue with encoding table #43

Open DBWillis opened 3 months ago

DBWillis commented 3 months ago

I am trying to table a lua table and encode it as a csv then write it to a csv file. my table is a simple table with only one column but I keep getting this error.

local fileOutput = ftcsv.encode(tagsOut,",") local file = assert(io.open(file),"w") file:write(fileOutput) file:close()

I get this error: /usr/qsc/www/designs/NgwUmIDsUYkk/lua/ftcsv/init.lua:768: bad argument #1 to 'pairs' (table expected, got string)

FourierTransformer commented 3 months ago

I tried encoding a single column table, and it seems to work okay. The table does need to be in a specific format, so you might be running into issues there.

Here's the example I tried:

local users = {
    {name="alice"},
    {name="bob"},
    {name="eve"}
}

print(ftcsv.encode(users, ","))

which prints out:

"name"
"alice"
"bob"
"eve"

Hopefully this helps a bit!