ftcsv icon indicating copy to clipboard operation
ftcsv copied to clipboard

Issue with encoding table

Open DBWillis opened this issue 1 year ago • 1 comments

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)

DBWillis avatar Aug 11 '24 18:08 DBWillis

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!

FourierTransformer avatar Aug 12 '24 03:08 FourierTransformer