csv2json 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +1 -1
- data/README.md +9 -9
- data/Rakefile +3 -1
- data/csv2json.gemspec +69 -0
- data/lib/csv2json-version.rb +3 -0
- data/lib/csv2json.rb +2 -2
- metadata +23 -1
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -1,15 +1,15 @@
|
|
1
|
-
|
1
|
+
# csv2json
|
2
2
|
|
3
3
|
Clients were sending me XLS files, but my webs consume JSON. So I needed to convert them to JSON easily from command-line.
|
4
4
|
Tried to google for solution and surprisingly enough nothing solid existed.
|
5
5
|
|
6
|
-
|
6
|
+
## Solution
|
7
7
|
|
8
8
|
- export XLS as a CSV file (I use OpenOffice.org for this)
|
9
9
|
- run `csv2json file.csv > file.json`
|
10
10
|
- there is no step 3
|
11
11
|
|
12
|
-
|
12
|
+
### Sample
|
13
13
|
|
14
14
|
note: make sure your XLS table has the first row with column names
|
15
15
|
|
@@ -44,11 +44,11 @@ gets turned into this JSON:
|
|
44
44
|
}
|
45
45
|
]
|
46
46
|
|
47
|
-
|
47
|
+
### Installation
|
48
48
|
|
49
49
|
`sudo gem install csv2json --source gemcutter.org`
|
50
50
|
|
51
|
-
|
51
|
+
### Usage
|
52
52
|
|
53
53
|
Usage: csv2json [INPUT] [OPTIONS]
|
54
54
|
|
@@ -57,7 +57,7 @@ gets turned into this JSON:
|
|
57
57
|
-h, --help Show this message
|
58
58
|
-v, --version Show version
|
59
59
|
|
60
|
-
|
60
|
+
### Alternative usage
|
61
61
|
|
62
62
|
common usage is `csv2json file.csv > file.json`
|
63
63
|
|
@@ -65,7 +65,7 @@ csv2json should behave like proper unix command-line utility working with pipes,
|
|
65
65
|
|
66
66
|
`cat file.csv | csv2json | gzip > file.json.gz`
|
67
67
|
|
68
|
-
|
68
|
+
### Usage as a library
|
69
69
|
|
70
70
|
with files
|
71
71
|
|
@@ -88,7 +88,7 @@ or in-memory
|
|
88
88
|
output.pos = 0
|
89
89
|
puts output.read
|
90
90
|
|
91
|
-
|
91
|
+
## Want to contribute?
|
92
92
|
|
93
93
|
* Fork the project.
|
94
94
|
* Make your feature addition or bug fix.
|
@@ -98,7 +98,7 @@ or in-memory
|
|
98
98
|
(if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
|
99
99
|
* Send me a pull request. Bonus points for topic branches.
|
100
100
|
|
101
|
-
|
101
|
+
## Copyright
|
102
102
|
|
103
103
|
Copyright (c) 2009 Antonin Hildebrand. See LICENSE for details.
|
104
104
|
|
data/Rakefile
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'rubygems'
|
2
2
|
require 'rake'
|
3
|
-
require File.join(File.expand_path(File.dirname(__FILE__)), 'lib', 'csv2json.rb')
|
3
|
+
require File.join(File.expand_path(File.dirname(__FILE__)), 'lib', 'csv2json-version.rb')
|
4
4
|
|
5
5
|
begin
|
6
6
|
require 'jeweler'
|
@@ -12,6 +12,8 @@ begin
|
|
12
12
|
gem.email = "antonin@hildebrand.cz"
|
13
13
|
gem.homepage = "http://github.com/darwin/csv2json"
|
14
14
|
gem.authors = ["Antonin Hildebrand"]
|
15
|
+
gem.add_dependency "json"
|
16
|
+
gem.add_dependency "fastercsv"
|
15
17
|
gem.add_development_dependency "shoulda", ">= 0"
|
16
18
|
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
17
19
|
end
|
data/csv2json.gemspec
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{csv2json}
|
8
|
+
s.version = "0.1.1"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Antonin Hildebrand"]
|
12
|
+
s.date = %q{2009-12-05}
|
13
|
+
s.default_executable = %q{csv2json}
|
14
|
+
s.description = %q{handy for converting xls files to json}
|
15
|
+
s.email = %q{antonin@hildebrand.cz}
|
16
|
+
s.executables = ["csv2json"]
|
17
|
+
s.extra_rdoc_files = [
|
18
|
+
"LICENSE",
|
19
|
+
"README.md"
|
20
|
+
]
|
21
|
+
s.files = [
|
22
|
+
".document",
|
23
|
+
".gitignore",
|
24
|
+
"LICENSE",
|
25
|
+
"README.md",
|
26
|
+
"Rakefile",
|
27
|
+
"bin/csv2json",
|
28
|
+
"csv2json.gemspec",
|
29
|
+
"lib/csv2json-version.rb",
|
30
|
+
"lib/csv2json.rb",
|
31
|
+
"test/fixtures/addresses.csv",
|
32
|
+
"test/fixtures/addresses.json",
|
33
|
+
"test/fixtures/photos.csv",
|
34
|
+
"test/fixtures/photos.json",
|
35
|
+
"test/fixtures/population.csv",
|
36
|
+
"test/fixtures/population.json",
|
37
|
+
"test/helper.rb",
|
38
|
+
"test/test_csv2json.rb"
|
39
|
+
]
|
40
|
+
s.homepage = %q{http://github.com/darwin/csv2json}
|
41
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
42
|
+
s.require_paths = ["lib"]
|
43
|
+
s.rubygems_version = %q{1.3.5}
|
44
|
+
s.summary = %q{.csv to .json converter}
|
45
|
+
s.test_files = [
|
46
|
+
"test/helper.rb",
|
47
|
+
"test/test_csv2json.rb"
|
48
|
+
]
|
49
|
+
|
50
|
+
if s.respond_to? :specification_version then
|
51
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
52
|
+
s.specification_version = 3
|
53
|
+
|
54
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
55
|
+
s.add_runtime_dependency(%q<json>, [">= 0"])
|
56
|
+
s.add_runtime_dependency(%q<fastercsv>, [">= 0"])
|
57
|
+
s.add_development_dependency(%q<shoulda>, [">= 0"])
|
58
|
+
else
|
59
|
+
s.add_dependency(%q<json>, [">= 0"])
|
60
|
+
s.add_dependency(%q<fastercsv>, [">= 0"])
|
61
|
+
s.add_dependency(%q<shoulda>, [">= 0"])
|
62
|
+
end
|
63
|
+
else
|
64
|
+
s.add_dependency(%q<json>, [">= 0"])
|
65
|
+
s.add_dependency(%q<fastercsv>, [">= 0"])
|
66
|
+
s.add_dependency(%q<shoulda>, [">= 0"])
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
data/lib/csv2json.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: csv2json
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Antonin Hildebrand
|
@@ -12,6 +12,26 @@ cert_chain: []
|
|
12
12
|
date: 2009-12-05 00:00:00 +01:00
|
13
13
|
default_executable: csv2json
|
14
14
|
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: json
|
17
|
+
type: :runtime
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: "0"
|
24
|
+
version:
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: fastercsv
|
27
|
+
type: :runtime
|
28
|
+
version_requirement:
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: "0"
|
34
|
+
version:
|
15
35
|
- !ruby/object:Gem::Dependency
|
16
36
|
name: shoulda
|
17
37
|
type: :development
|
@@ -38,6 +58,8 @@ files:
|
|
38
58
|
- README.md
|
39
59
|
- Rakefile
|
40
60
|
- bin/csv2json
|
61
|
+
- csv2json.gemspec
|
62
|
+
- lib/csv2json-version.rb
|
41
63
|
- lib/csv2json.rb
|
42
64
|
- test/fixtures/addresses.csv
|
43
65
|
- test/fixtures/addresses.json
|