smarter_csv 1.0.5 → 1.0.6
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/README.md +3 -4
- data/lib/smarter_csv.rb +1 -1
- data/lib/smarter_csv/smarter_csv.rb +12 -2
- data/lib/smarter_csv/version.rb +1 -1
- data/smarter_csv.gemspec +2 -1
- metadata +35 -38
- checksums.yaml +0 -7
data/README.md
CHANGED
@@ -194,12 +194,11 @@ Or install it yourself as:
|
|
194
194
|
$ gem install smarter_csv
|
195
195
|
|
196
196
|
|
197
|
-
##
|
198
|
-
|
199
|
-
* if :col_sep (e.g. a comma) appears inside a quoted field, smarter_csv <= 1.0.4 incorrectly splits on that :col_sep
|
197
|
+
## Changes
|
200
198
|
|
199
|
+
#### 1.0.6 (2013-05-19)
|
201
200
|
|
202
|
-
|
201
|
+
* bugfix : quoted fields are now correctly parsed
|
203
202
|
|
204
203
|
#### 1.0.5 (2013-05-08)
|
205
204
|
|
data/lib/smarter_csv.rb
CHANGED
@@ -22,7 +22,12 @@ module SmarterCSV
|
|
22
22
|
# the first line of a CSV file contains the header .. it might be commented out, so we need to read it anyhow
|
23
23
|
header = f.readline.sub(options[:comment_regexp],'').chomp(options[:row_sep])
|
24
24
|
header = header.gsub(options[:strip_chars_from_headers], '') if options[:strip_chars_from_headers]
|
25
|
-
|
25
|
+
if header =~ %r{#{options[:quote_char]}}
|
26
|
+
file_headerA = CSV.parse( header ).flatten
|
27
|
+
else
|
28
|
+
file_headerA = header.split(options[:col_sep])
|
29
|
+
end
|
30
|
+
file_headerA.map!{|x| x.gsub(%r/options[:quote_char]/,'') }
|
26
31
|
file_headerA.map!{|x| x.strip} if options[:strip_whitespace]
|
27
32
|
file_headerA.map!{|x| x.gsub(/\s+/,'_')}
|
28
33
|
file_headerA.map!{|x| x.downcase } if options[:downcase_header]
|
@@ -69,7 +74,12 @@ module SmarterCSV
|
|
69
74
|
next if line =~ options[:comment_regexp] # ignore all comment lines if there are any
|
70
75
|
line.chomp! # will use $/ which is set to options[:col_sep]
|
71
76
|
|
72
|
-
|
77
|
+
if line =~ %r{#{options[:quote_char]}}
|
78
|
+
dataA = CSV.parse( line ).flatten
|
79
|
+
else
|
80
|
+
dataA = line.split(options[:col_sep])
|
81
|
+
end
|
82
|
+
dataA.map!{|x| x.gsub(%r/options[:quote_char]/,'') }
|
73
83
|
dataA.map!{|x| x.strip} if options[:strip_whitespace]
|
74
84
|
hash = Hash.zip(headerA,dataA) # from Facets of Ruby library
|
75
85
|
# make sure we delete any key/value pairs from the hash, which the user wanted to delete:
|
data/lib/smarter_csv/version.rb
CHANGED
data/smarter_csv.gemspec
CHANGED
@@ -6,12 +6,13 @@ Gem::Specification.new do |gem|
|
|
6
6
|
gem.email = ["tilo.sloboda@gmail.com\n"]
|
7
7
|
gem.description = %q{Ruby Gem for smarter importing of CSV Files as Array(s) of Hashes, with optional features for processing large files in parallel, embedded comments, unusual field- and record-separators, flexible mapping of CSV-headers to Hash-keys}
|
8
8
|
gem.summary = %q{Ruby Gem for smarter importing of CSV Files (and CSV-like files), with lots of optional features, e.g. chunked processing for huge CSV files}
|
9
|
-
gem.homepage = ""
|
9
|
+
gem.homepage = "https://github.com/tilo/smarter_csv"
|
10
10
|
|
11
11
|
gem.files = `git ls-files`.split($\)
|
12
12
|
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
13
13
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
14
14
|
gem.name = "smarter_csv"
|
15
15
|
gem.require_paths = ["lib"]
|
16
|
+
gem.requirements = ['csv'] # for CSV.parse() only needed in case we have quoted fields
|
16
17
|
gem.version = SmarterCSV::VERSION
|
17
18
|
end
|
metadata
CHANGED
@@ -1,31 +1,29 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: smarter_csv
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.6
|
5
|
+
prerelease:
|
5
6
|
platform: ruby
|
6
|
-
authors:
|
7
|
-
-
|
8
|
-
Tilo Sloboda
|
7
|
+
authors:
|
8
|
+
- ! 'Tilo Sloboda
|
9
9
|
|
10
|
+
'
|
10
11
|
autorequire:
|
11
12
|
bindir: bin
|
12
13
|
cert_chain: []
|
13
|
-
|
14
|
-
date: 2013-05-09 00:00:00 Z
|
14
|
+
date: 2013-05-20 00:00:00.000000000 Z
|
15
15
|
dependencies: []
|
16
|
+
description: Ruby Gem for smarter importing of CSV Files as Array(s) of Hashes, with
|
17
|
+
optional features for processing large files in parallel, embedded comments, unusual
|
18
|
+
field- and record-separators, flexible mapping of CSV-headers to Hash-keys
|
19
|
+
email:
|
20
|
+
- ! 'tilo.sloboda@gmail.com
|
16
21
|
|
17
|
-
|
18
|
-
email:
|
19
|
-
- |
|
20
|
-
tilo.sloboda@gmail.com
|
21
|
-
|
22
|
+
'
|
22
23
|
executables: []
|
23
|
-
|
24
24
|
extensions: []
|
25
|
-
|
26
25
|
extra_rdoc_files: []
|
27
|
-
|
28
|
-
files:
|
26
|
+
files:
|
29
27
|
- .gitignore
|
30
28
|
- .rvmrc
|
31
29
|
- Gemfile
|
@@ -37,31 +35,30 @@ files:
|
|
37
35
|
- lib/smarter_csv/smarter_csv.rb
|
38
36
|
- lib/smarter_csv/version.rb
|
39
37
|
- smarter_csv.gemspec
|
40
|
-
homepage:
|
38
|
+
homepage: https://github.com/tilo/smarter_csv
|
41
39
|
licenses: []
|
42
|
-
|
43
|
-
metadata: {}
|
44
|
-
|
45
40
|
post_install_message:
|
46
41
|
rdoc_options: []
|
47
|
-
|
48
|
-
require_paths:
|
42
|
+
require_paths:
|
49
43
|
- lib
|
50
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
- !ruby/object:Gem::Version
|
55
|
-
version:
|
56
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
44
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
45
|
+
none: false
|
46
|
+
requirements:
|
47
|
+
- - ! '>='
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: '0'
|
50
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
51
|
+
none: false
|
52
|
+
requirements:
|
53
|
+
- - ! '>='
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '0'
|
56
|
+
requirements:
|
57
|
+
- csv
|
61
58
|
rubyforge_project:
|
62
|
-
rubygems_version:
|
59
|
+
rubygems_version: 1.8.15
|
63
60
|
signing_key:
|
64
|
-
specification_version:
|
65
|
-
summary: Ruby Gem for smarter importing of CSV Files (and CSV-like files), with lots
|
61
|
+
specification_version: 3
|
62
|
+
summary: Ruby Gem for smarter importing of CSV Files (and CSV-like files), with lots
|
63
|
+
of optional features, e.g. chunked processing for huge CSV files
|
66
64
|
test_files: []
|
67
|
-
|
checksums.yaml
DELETED
@@ -1,7 +0,0 @@
|
|
1
|
-
---
|
2
|
-
SHA1:
|
3
|
-
metadata.gz: ed29542688f14930b2c88be160a092ba0e7e0398
|
4
|
-
data.tar.gz: 6ce2d29c27af35540f83a44f7c1af1a1f3da988e
|
5
|
-
SHA512:
|
6
|
-
metadata.gz: a88bbcfc69a77beb3ef9fbcd68d48d17880e57264f4755426d0f44c64d06905ba496de9805f48cb2c83373da2ba0bb893dd71a55556fed61016b6696a4a35d95
|
7
|
-
data.tar.gz: 73de0af3b952a8dc4a32f1c823162f718aeedd5304f553b4690100a245c81d68edda0280e3646e965e5c3d260176a884ea64f6a43adb3c62ae26e4bcef2bbfc7
|