nebulous 0.0.4 → 0.0.5
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.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +42 -0
- data/lib/nebulous/input/parsing.rb +1 -1
- data/lib/nebulous/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bf7777af004a3e807166622d2e9cc01beb8b6d04
|
4
|
+
data.tar.gz: 59ad738d6c9b7ff3a81e9f476d1727f187dd9537
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d9bc42df4140f2965205a2f8ae8379df12e9e18465b80a4264b74952d2ba7b262b4b50d78695bda7dc4a2889bcb4e18c4ef9e3268db7524cfd1cdf2b5ddd8d7a
|
7
|
+
data.tar.gz: 3bc3793318ea8bc82e0d839c0044a210c6906fe2ac5fe2652b214f9df7532e62d0ff2ccfce34add2ffbf61601219581c5b38a4593952f1db586cf32a70f12c82
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -18,6 +18,48 @@ Or install it yourself as:
|
|
18
18
|
|
19
19
|
## Usage
|
20
20
|
|
21
|
+
Nebulous is a bit easier going than other CSV libraries for Ruby. It will parse
|
22
|
+
data that would otherwise fail with Ruby's CSV and supports the common problems
|
23
|
+
that are present in real-world CSV files. Nebulous will also try to intelligently
|
24
|
+
determine the column delimiters and line terminators before parsing so you don't
|
25
|
+
have to. Which makes handling CSV file uploads a breeze when you have no idea
|
26
|
+
what you might get. Let's cover some examples.
|
27
|
+
|
28
|
+
Nebulous.process "path/to/file.csv"
|
29
|
+
=> [{:first_name=>"Meghan", :last_name=>"Koch"},
|
30
|
+
{:first_name=>"Genoveva", :last_name=>"Dare"}, ...]
|
31
|
+
|
32
|
+
Or process within a block in chunks of 10
|
33
|
+
|
34
|
+
Nebulous.process "path/to/file.csv", chunk: 10 do |chunk|
|
35
|
+
p chunk
|
36
|
+
end
|
37
|
+
=> [{:first_name=>"Meghan", :last_name=>"Koch"},
|
38
|
+
{:first_name=>"Genoveva", :last_name=>"Dare"}, ...]
|
39
|
+
=> [{:first_name=>"Chad", :last_name=>"Anderson"},
|
40
|
+
{:first_name=>"Arnold", :last_name=>"Yundt"}, ...]
|
41
|
+
|
42
|
+
|
43
|
+
Or provide your own header mapping to normalize columns:
|
44
|
+
|
45
|
+
map = {first_name: :col1, last_name: :col2 }
|
46
|
+
Nebulous.process "path/to/file.csv", mapping: map
|
47
|
+
=> [{:col1=>"どーもありがとう", :col2=>"ミスター·ロボット"},
|
48
|
+
{:col1=>"Meghan", :col2=>"Koch"},
|
49
|
+
{:col1=>"Genoveva", :col2=>"Dare"}]
|
50
|
+
|
51
|
+
|
52
|
+
If you know your CSV file does not contain headers it will return simple Arrays.
|
53
|
+
|
54
|
+
Nebulous.process "path/to/file.csv", headers: false
|
55
|
+
=> [["どーもありがとう", "ミスター·ロボット"],
|
56
|
+
["Meghan", "Koch"],
|
57
|
+
["Genoveva", "Dare"]]
|
58
|
+
|
59
|
+
Or provide a limit:
|
60
|
+
|
61
|
+
Nebulous.process "path/to/file.csv", limit: 1
|
62
|
+
=> [{:first_name=>"どーもありがとう", :last_name=>"ミスター·ロボット"}]
|
21
63
|
|
22
64
|
|
23
65
|
## Contributing
|
data/lib/nebulous/version.rb
CHANGED