npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

evalcsv

v1.1.23

Published

Eval Csv is a command line tool for converting csv files to json object.

Downloads

8

Readme

EvalCsv

EvalCsv是一个可以把csv文件转换为json文件的命令行工具。
csv里面可以填一个对象:
	p
	{x:0,y:1}
还可以填一个数组:
	arr
	[{x:0,y:1}, {x:2,y:3}]
new一个对象也可以:
	m
	new Map()
支持javascript代码,语法简洁,错误提示全面, 因为这个程序仅仅是把csv里面的元素读取出来eval而已……

Solution

对于csv文件中的每一个元素value, 假定key为标题行对应列的值, evalcsv使用了一个很简单的办法来把csv文件转换为json对象:

		eval("row." + key + " = " + value + ";");
        
有木有感觉到用csv表示对象, 数组等复杂数据原来是这么容易的事情?
用node.js的小伙伴们, 直接require这个json文件开始愉快的工作吧。

想要把csv资源打包的朋友们, 可以使用json2pb把json对象用protobuf打包。

Install

  1. Install node.js

  2. Install with npm

    npm install -g evalcsv

Usage

Usage: evalcsv [options] files
Options:
  -h, --help                   Display this information.
  -v, --version                Print the compiler version.
  -e, --encoding               Set input file encoding, default encoding is 'gbk'.
  -k, --key                    Set the line number of keys, default is 2.
  -s, --start                  Set the starting line number for parsing, default is 3.
  -f, --format                 Set the output format, default is {"rows":%s}

Example

motion.csv
    motion_id,name,privileges,type,category
    motion_id,name,privileges,type,category
    11001,"""跪姿肩部下沉""","['owner', 'admin', 'user', 'guest']","""热身""","""胸"""
    11002,"""直体肩部下沉""","['owner', 'admin', 'user', 'guest']","""热身""","""胸"""

command line
    evalcsv motion.csv
    
motion.json
	{
		"rows": [
			{
				"motion_id": 11001,
				"name": "跪姿肩部下沉",
				"privileges": [
					"owner",
					"admin",
					"user",
					"guest"
				],
				"type": "热身",
				"category": "胸",
			},
			{
				"motion_id": 11002,
				"name": "直体肩部下沉",
				"privileges": [
					"owner",
					"admin",
					"user",
					"guest"
				],
				"type": "热身",
				"category": "胸",
			}
		]
	}

Author

@randyliu

Licence

See the MIT License