GithubHelp home page GithubHelp logo

Comments (9)

geoffleyland avatar geoffleyland commented on August 22, 2024

Try csv.use(io.stdin) or maybe just csv.use(), I think?

from lua-csv.

lateefj avatar lateefj commented on August 22, 2024

Both seem to give me this error (lua 5.2 and luajit):

lua: user_comment_size/lua/comment_count.lua:6: attempt to call a table value
stack traceback:
        user_comment_size/lua/comment_count.lua:6: in main chunk
        [C]: in ?

from lua-csv.

geoffleyland avatar geoffleyland commented on August 22, 2024

You're forgetting a :lines()

from lua-csv.

lateefj avatar lateefj commented on August 22, 2024
local csv = require("csv")

local count = 0
local size = 0

for fields in csv.use(io.stdin:lines()) do 
--for line in io.stdin:lines() do
  for i, v in ipairs(fields) do 
    size = size + 1
    print(i, v) 
  end
  count = count + 1
  --io.write("count " , count, " size ", size, "\r")
end
io.write("count " , count, " size ", size, "\n")

from lua-csv.

geoffleyland avatar geoffleyland commented on August 22, 2024

Try

for fields in csv.use(io.stdin):lines() do 

from lua-csv.

lateefj avatar lateefj commented on August 22, 2024

Error:

lua: user_comment_size/lua/comment_count.lua:6: /usr/local/share/lua/5.2/csv.lua:150: attempt to index local 'parameters' (a nil value)
stack traceback:
        [C]: in function 'for iterator'
        user_comment_size/lua/comment_count.lua:6: in main chun

from lua-csv.

lateefj avatar lateefj commented on August 22, 2024

Worked like this:

for fields in csv.use(io.stdin, {}):lines() do  

from lua-csv.

lateefj avatar lateefj commented on August 22, 2024

Thanks a lot!

from lua-csv.

geoffleyland avatar geoffleyland commented on August 22, 2024

Weird, you shouldn't need to do that, and you shouldn't have got an error at line 150. This line is there so that parameters is optional. Oh well...

from lua-csv.

Related Issues (7)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.