idata 1.2.4 → 1.2.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/icsvutils +19 -13
- data/lib/idata/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: ef49d322db71fc0f179ff0d2ca1412998821694c
|
4
|
+
data.tar.gz: 8b10462121074019fc66ed5e38587bf4515aa27c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a2de21d257026f1bfda26dc4d552c64a946f4363438227af9383d9ea2a4d05cbd582731f4f14e30faa8aec885f65248779a198632038f02d9870ac9e13ff8894
|
7
|
+
data.tar.gz: bfd0ba660ec70ca98e032c94afd364876c4f9be799360feea8e2e312f6a2e77cbed15024450ac485220183639fa521cc1354391b6e68c6bcce18e96895659879
|
data/bin/icsvutils
CHANGED
@@ -29,29 +29,37 @@ def error(msg)
|
|
29
29
|
end
|
30
30
|
|
31
31
|
$options = {:actions => {}}
|
32
|
-
parser = OptionParser.new("",
|
33
|
-
opts.banner = "Program: icsvutils #{
|
32
|
+
parser = OptionParser.new("", 30) do |opts|
|
33
|
+
opts.banner = "Program: icsvutils #{Idata::VERSION}\nAuthor: Gaugau\nUsage: iscvutils file [options]\n"
|
34
34
|
opts.version = 1
|
35
|
-
|
36
|
-
opts.separator ""
|
37
|
-
opts.separator "Command options:"
|
38
35
|
|
39
36
|
opts.on("--set-delim DELIMITER", "Set file delimiter") do |v|
|
40
37
|
$options[:actions][:set_delim] = v
|
41
38
|
end
|
42
39
|
|
43
|
-
opts.on("--set-encoding
|
40
|
+
opts.on("--set-encoding ENCODING", "Set file encoding. Valid values include: UTF8, UTF16, ISO, etc.") do |v|
|
44
41
|
$options[:actions][:set_encoding] = v
|
45
42
|
end
|
46
|
-
|
47
|
-
opts.separator ""
|
48
|
-
opts.separator "Common options:"
|
49
43
|
|
50
44
|
opts.on_tail('--help', 'Displays this help') do
|
51
45
|
puts opts, "", help
|
52
46
|
exit
|
53
47
|
end
|
54
|
-
|
48
|
+
end
|
49
|
+
|
50
|
+
def help
|
51
|
+
return <<-eos
|
52
|
+
Example:
|
53
|
+
-------------------------------------------------------
|
54
|
+
Convert a tabular file to a tab-separated one.\nNote that the original file format will be auto detected
|
55
|
+
|
56
|
+
icsvutils /path/to/file --set-delim=$'\\t'
|
57
|
+
|
58
|
+
Convert a tabular file to a CSV (comma-delimited) one
|
59
|
+
|
60
|
+
icsvutils /path/to/file --set-delim=","
|
61
|
+
|
62
|
+
eos
|
55
63
|
end
|
56
64
|
|
57
65
|
parser.parse!
|
@@ -83,8 +91,6 @@ $options[:quote] ||= CSV_DEFAULT_QUOTE
|
|
83
91
|
$options[:table] ||= 'items'
|
84
92
|
$options[:actions][:set_delim] ||= CSV_DEFAULT_DELIMITER
|
85
93
|
|
86
|
-
p $options
|
87
|
-
|
88
94
|
$tmpfile = "/tmp/#{Digest::SHA1.hexdigest(rand(100000).to_s)}.csv"
|
89
95
|
|
90
96
|
class String
|
@@ -189,7 +195,7 @@ class MyParser
|
|
189
195
|
|
190
196
|
create_table_sql = headers.map{|e| "\"#{e}\" text"}.join(",")
|
191
197
|
create_table_sql = "create table #{$options[:table]}( #{create_table_sql} );"
|
192
|
-
|
198
|
+
|
193
199
|
importcmd = %Q{
|
194
200
|
sqlite3 /tmp/i <<!
|
195
201
|
#{create_table_sql}
|
data/lib/idata/version.rb
CHANGED