elf_ham 0.1.0 → 0.2.0
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/README.md +57 -3
- data/lib/elf_ham/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 31c43f2fb19baa2d2eb0e9458ea9ccadfd6f211a4372db4543b4cd5ef3b8a5cf
|
4
|
+
data.tar.gz: cf656cb6fbf83e9b8edafaecc189692ad0dbb79cd7b9db332eff91738b073674
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4f39189b74b044d6089b9698ec62c10dd0bef0fe8cb950044dae1d80a059b622584c572629e43cdafa5555d3ab2851dfbcb8612a87a08ced141831f235e6f0f0
|
7
|
+
data.tar.gz: 43f5332a7924698e03f2159ecb3f30599cae63d1618203b46afca79e753d5e965b4decbb6d2da84de6faa78bcee53a3bd2f24174285c1035529ba52ae6bd865f
|
data/README.md
CHANGED
@@ -2,12 +2,66 @@
|
|
2
2
|
|
3
3
|
ElfHam is an extremely simple utility gem that's useful for transform CSVs.
|
4
4
|
|
5
|
-
##
|
5
|
+
## tldr;
|
6
6
|
|
7
|
-
```
|
8
|
-
|
7
|
+
```ruby
|
8
|
+
require "elf_ham"
|
9
|
+
|
10
|
+
# Load your CSV:
|
11
|
+
elf_ham = ElfHam.new(ARGF.read)
|
12
|
+
|
13
|
+
# Filter rows:
|
14
|
+
elf_ham.select { |row| row["header2"] != "b" }
|
15
|
+
|
16
|
+
# Transform rows:
|
17
|
+
elf_ham.transform do |row|
|
18
|
+
row["header3"] = "elfham"
|
19
|
+
end
|
20
|
+
|
21
|
+
# Print the result
|
22
|
+
puts elf_ham.output
|
9
23
|
```
|
10
24
|
|
25
|
+
## Instructions
|
26
|
+
|
27
|
+
1. Install the gem:
|
28
|
+
|
29
|
+
```sh
|
30
|
+
gem install elf_ham
|
31
|
+
```
|
32
|
+
|
33
|
+
2. Create a transformation script:
|
34
|
+
|
35
|
+
```sh
|
36
|
+
echo '#!/usr/bin/env ruby
|
37
|
+
|
38
|
+
require "elf_ham"
|
39
|
+
|
40
|
+
puts ElfHam.new(ARGF.read).select do |row|
|
41
|
+
row["header2"] != "b"
|
42
|
+
end.transform do |row|
|
43
|
+
row["header3"] = "elfham"
|
44
|
+
end.output' > transform.rb
|
45
|
+
```
|
46
|
+
|
47
|
+
3. Make the script executable:
|
48
|
+
|
49
|
+
```sh
|
50
|
+
chmod u+x transform.rb
|
51
|
+
```
|
52
|
+
|
53
|
+
4. Edit the script to your liking.
|
54
|
+
|
55
|
+
5. Run it:
|
56
|
+
|
57
|
+
```sh
|
58
|
+
transform.rb path/to/your.csv > transformed.csv
|
59
|
+
|
60
|
+
# or
|
61
|
+
|
62
|
+
cat path/to/your.csv | transform.rb > transformed.csv
|
63
|
+
```
|
64
|
+
|
11
65
|
## Development
|
12
66
|
|
13
67
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run
|
data/lib/elf_ham/version.rb
CHANGED