Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with encoding table #43

Open
DBWillis opened this issue Aug 11, 2024 · 1 comment
Open

Issue with encoding table #43

DBWillis opened this issue Aug 11, 2024 · 1 comment

Comments

@DBWillis
Copy link

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
Copy link
Owner

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants