• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

clementfarabet/lua---csv: A package to read and write CSV. Provides high-level d ...

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称(OpenSource Name):

clementfarabet/lua---csv

开源软件地址(OpenSource Url):

https://github.com/clementfarabet/lua---csv

开源编程语言(OpenSource Language):

Lua 92.0%

开源软件介绍(OpenSource Introduction):

csvigo: a package to handle CSV files (read and write).

Install:

First install Torch7 (www.torch.ch) then simply install this package using luarocks:

luarocks install csvigo

Use:

The library provides 2 high-level functions: csvigo.load and csvigo.save. To get help on these functions, simply do:

> csvigo.save()
> csvigo.load()

Loading a CSV file in 'query' mode gives you a convenient query function that you can use to query subsets of your original CSV file. To get help on this query function, simply do:

> query = csvigo.load{path='somefile.csv', mode='query'}
> query('help')
-- print some help
> all = query('all')
> subset = query('union', {somevar=someval, someothervar={val1, val2}})

Large CSV mode

CSVigo supports efficient loading of very large CSV files into memory. The loaded data structure is a read-only table with efficiency hidden under the hood.

Loading:

m = csvigo.load({path = "my_large.csv", mode = "large"})

Printing by default only prints first 10 and last 10 rows

print(m)

Individual element access

print(m[32])

Size of table:

print(#m)

For loop over entries:

Type 1:

for i=1, #m do
    print(m[i]) -- get element
end

Type 2:

for k,v in ipairs(m) do
    print(k)
    print(v)
end

Type 3:

for k,v in pairs(m) do
    print(k)
    print(v)
end

Read-only table

-- read only table, will error here:
m[13] = 'a'



鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap