smarter_csv 1.3.0 → 1.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/CHANGELOG.md +181 -0
- data/CONTRIBUTORS.md +46 -0
- data/LICENSE.txt +21 -0
- data/README.md +50 -239
- data/Rakefile +8 -15
- data/lib/smarter_csv/smarter_csv.rb +114 -38
- data/lib/smarter_csv/version.rb +1 -1
- data/lib/smarter_csv.rb +8 -0
- data/smarter_csv.gemspec +20 -16
- data/spec/fixtures/additional_separator.csv +6 -0
- data/spec/fixtures/empty_columns_1.csv +2 -0
- data/spec/fixtures/empty_columns_2.csv +2 -0
- data/spec/fixtures/hard_sample.csv +2 -0
- data/spec/fixtures/numeric.csv +1 -1
- data/spec/fixtures/separator_colon.csv +4 -0
- data/spec/fixtures/separator_comma.csv +4 -0
- data/spec/fixtures/separator_pipe.csv +4 -0
- data/spec/fixtures/{separator.csv → separator_semi.csv} +0 -0
- data/spec/fixtures/separator_tab.csv +4 -0
- data/spec/smarter_csv/additional_separator_spec.rb +45 -0
- data/spec/smarter_csv/binary_file2_spec.rb +1 -1
- data/spec/smarter_csv/blank_spec.rb +55 -0
- data/spec/smarter_csv/carriage_return_spec.rb +27 -7
- data/spec/smarter_csv/column_separator_spec.rb +89 -5
- data/spec/smarter_csv/empty_columns_spec.rb +74 -0
- data/spec/smarter_csv/hard_sample_spec.rb +24 -0
- data/spec/smarter_csv/ignore_comments_spec.rb +45 -30
- metadata +50 -13
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 23032eface2d1d918bcd6daabb4ca79e03096612bda1017d06f1b0542d0c4619
|
4
|
+
data.tar.gz: 12b68eeafc4f83c06b66da45b27da5e716675bff1e77be2362c2c10006821d9c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5b84337de25ed7a8492088b82342e6d3b16d1fdc95120f9699986aee7d9416a51cfec981eb125e0d4b17600bc1c06c52eb3b2251857668210d9402e95bb75860
|
7
|
+
data.tar.gz: b26b40b49bf6d739df9cd5deb477c33fdc22c54ed88c96f87e401fef789aedf3f9c55d25df60e4900a1e2a3c8bc0fc6e78018b128ab6ac14062fd97f694f3568
|
data/.gitignore
CHANGED
data/CHANGELOG.md
ADDED
@@ -0,0 +1,181 @@
|
|
1
|
+
|
2
|
+
# SmarterCSV 1.x Change Log
|
3
|
+
|
4
|
+
## 1.5.0 (2022-04-25)
|
5
|
+
* fixed bug with trailing col_sep characters, introduced in 1.4.0
|
6
|
+
* Fix deprecation warning in Ruby 3.0.3 / $INPUT_RECORD_SEPARATOR (thanks to Joel Fouse )
|
7
|
+
|
8
|
+
* changed default for `comment_regexp` to be `nil` for a safer default behavior (thanks to David Lazar)
|
9
|
+
**Note**
|
10
|
+
This no longer assumes that lines starting with `#` are comments.
|
11
|
+
If you want to treat lines starting with '#' as comments, use `comment_regexp: /\A#/`
|
12
|
+
|
13
|
+
## 1.4.2 (2022-02-12)
|
14
|
+
* fixed issue with simplecov
|
15
|
+
|
16
|
+
## 1.4.1 (2022-02-12) (PULLED)
|
17
|
+
* minor fix: also support `col_sep: :auto`
|
18
|
+
* added simplecov
|
19
|
+
|
20
|
+
## 1.4.0 (2022-02-11)
|
21
|
+
* dropped GPL license, smarter_csv is now only using the MIT License
|
22
|
+
* added experimental option `col_sep: 'auto` to auto-detect the column separator (issue #183)
|
23
|
+
The default behavior is still to assume `,` is the column separator.
|
24
|
+
* fixed buggy behavior when using `remove_empty_values: false` (issue #168)
|
25
|
+
* fixed Ruby 3.0 deprecation
|
26
|
+
|
27
|
+
## 1.3.0 (2022-02-06) Breaking code change if you used `--key_mappings`
|
28
|
+
* fix bug for key_mappings (issue #181)
|
29
|
+
The values of the `key_mappings` hash will now be used "as is", and no longer forced to be symbols
|
30
|
+
|
31
|
+
**Users with existing code with `--key_mappings` need to change their code** to
|
32
|
+
* either use symbols in the `key_mapping` hash
|
33
|
+
* or change the expected keys from symbols to strings
|
34
|
+
|
35
|
+
## 1.2.9 (2021-11-22) (PULLED)
|
36
|
+
* fix bug for key_mappings (issue #181)
|
37
|
+
The values of the `key_mappings` hash will now be used "as is", and no longer forced to be symbols
|
38
|
+
|
39
|
+
## 1.2.8 (2020-02-04)
|
40
|
+
* fix deprecation warnings on Ruby 2.7 (thank to Diego Salido)
|
41
|
+
|
42
|
+
## 1.2.7 (2020-02-03)
|
43
|
+
|
44
|
+
## 1.2.6 (2018-11-13)
|
45
|
+
* fixing error caused by calling f.close when we do not hand in a file
|
46
|
+
|
47
|
+
## 1.2.5 (2018-09-16)
|
48
|
+
* fixing issue #136 with comments in CSV files
|
49
|
+
* fixing error class hierarchy
|
50
|
+
|
51
|
+
## 1.2.4 (2018-08-06)
|
52
|
+
* using Rails blank? if it's available
|
53
|
+
|
54
|
+
## 1.2.3 (2018-01-27)
|
55
|
+
* fixed regression / test
|
56
|
+
* fuxed quote_char interpolation for headers, but not data (thanks to Colin Petruno)
|
57
|
+
* bugfix (thanks to Joshua Smith for reporting)
|
58
|
+
|
59
|
+
## 1.2.0 (2018-01-20)
|
60
|
+
* add default validation that a header can only appear once
|
61
|
+
* add option `required_headers`
|
62
|
+
|
63
|
+
## 1.1.5 (2017-11-05)
|
64
|
+
* fix issue with invalid byte sequences in header (issue #103, thanks to Dave Myron)
|
65
|
+
* fix issue with invalid byte sequences in multi-line data (thanks to Ivan Ushakov)
|
66
|
+
* analyze only 500 characters by default when `:row_sep => :auto` is used.
|
67
|
+
added option `row_sep_auto_chars` to change the default if necessary. (thanks to Matthieu Paret)
|
68
|
+
|
69
|
+
## 1.1.4 (2017-01-16)
|
70
|
+
* fixing UTF-8 related bug which was introduced in 1.1.2 (thanks to Tirdad C.)
|
71
|
+
|
72
|
+
## 1.1.3 (2016-12-30)
|
73
|
+
* added warning when options indicate UTF-8 processing, but input filehandle is not opened with r:UTF-8 option
|
74
|
+
|
75
|
+
## 1.1.2 (2016-12-29)
|
76
|
+
* added option `invalid_byte_sequence` (thanks to polycarpou)
|
77
|
+
* added comments on handling of UTF-8 encoding when opening from File vs. OpenURI (thanks to KevinColemanInc)
|
78
|
+
|
79
|
+
## 1.1.1 (2016-11-26)
|
80
|
+
* added option to `skip_lines` (thanks to wal)
|
81
|
+
* added option to `force_utf8` encoding (thanks to jordangraft)
|
82
|
+
* bugfix if no headers in input data (thanks to esBeee)
|
83
|
+
* ensure input file is closed (thanks to waldyr)
|
84
|
+
* improved verbose output (thankd to benmaher)
|
85
|
+
* improved documentation
|
86
|
+
|
87
|
+
## 1.1.0 (2015-07-26)
|
88
|
+
* added feature :value_converters, which allows parsing of dates, money, and other things (thanks to Raphaël Bleuse, Lucas Camargo de Almeida, Alejandro)
|
89
|
+
* added error if :headers_in_file is set to false, and no :user_provided_headers are given (thanks to innhyu)
|
90
|
+
* added support to convert dashes to underscore characters in headers (thanks to César Camacho)
|
91
|
+
* fixing automatic detection of \r\n line-endings (thanks to feens)
|
92
|
+
|
93
|
+
## 1.0.19 (2014-10-29)
|
94
|
+
* added option :keep_original_headers to keep CSV-headers as-is (thanks to Benjamin Thouret)
|
95
|
+
|
96
|
+
## 1.0.18 (2014-10-27)
|
97
|
+
* added support for multi-line fields / csv fields containing CR (thanks to Chris Hilton) (issue #31)
|
98
|
+
|
99
|
+
## 1.0.17 (2014-01-13)
|
100
|
+
* added option to set :row_sep to :auto , for automatic detection of the row-separator (issue #22)
|
101
|
+
|
102
|
+
## 1.0.16 (2014-01-13)
|
103
|
+
* :convert_values_to_numeric option can now be qualified with :except or :only (thanks to Hugo Lepetit)
|
104
|
+
* removed deprecated `process_csv` method
|
105
|
+
|
106
|
+
## 1.0.15 (2013-12-07)
|
107
|
+
* new option:
|
108
|
+
* :remove_unmapped_keys to completely ignore columns which were not mapped with :key_mapping (thanks to Dave Sanders)
|
109
|
+
|
110
|
+
## 1.0.14 (2013-11-01)
|
111
|
+
* added GPL-2 and MIT license to GEM spec file; if you need another license contact me
|
112
|
+
|
113
|
+
## 1.0.12 (2013-10-15)
|
114
|
+
* added RSpec tests
|
115
|
+
|
116
|
+
## 1.0.11 (2013-09-28)
|
117
|
+
* bugfix : fixed issue #18 - fixing issue with last chunk not being properly returned (thanks to Jordan Running)
|
118
|
+
* added RSpec tests
|
119
|
+
|
120
|
+
## 1.0.10 (2013-06-26)
|
121
|
+
* bugfix : fixed issue #14 - passing options along to CSV.parse (thanks to Marcos Zimmermann)
|
122
|
+
|
123
|
+
## 1.0.9 (2013-06-19)
|
124
|
+
* bugfix : fixed issue #13 with negative integers and floats not being correctly converted (thanks to Graham Wetzler)
|
125
|
+
|
126
|
+
## 1.0.8 (2013-06-01)
|
127
|
+
|
128
|
+
* bugfix : fixed issue with nil values in inputs with quote-char (thanks to Félix Bellanger)
|
129
|
+
* new options:
|
130
|
+
* :force_simple_split : to force simiple splitting on :col_sep character for non-standard CSV-files. e.g. without properly escaped :quote_char
|
131
|
+
* :verbose : print out line number while processing (to track down problems in input files)
|
132
|
+
|
133
|
+
## 1.0.7 (2013-05-20)
|
134
|
+
|
135
|
+
* allowing process to work with objects with a 'readline' method (thanks to taq)
|
136
|
+
* added options:
|
137
|
+
* :file_encoding : defaults to utf8 (thanks to MrTin, Paxa)
|
138
|
+
|
139
|
+
## 1.0.6 (2013-05-19)
|
140
|
+
|
141
|
+
* bugfix : quoted fields are now correctly parsed
|
142
|
+
|
143
|
+
## 1.0.5 (2013-05-08)
|
144
|
+
|
145
|
+
* bugfix : for :headers_in_file option
|
146
|
+
|
147
|
+
## 1.0.4 (2012-08-17)
|
148
|
+
|
149
|
+
* renamed the following options:
|
150
|
+
* :strip_whitepace_from_values => :strip_whitespace - removes leading/trailing whitespace from headers and values
|
151
|
+
|
152
|
+
## 1.0.3 (2012-08-16)
|
153
|
+
|
154
|
+
* added the following options:
|
155
|
+
* :strip_whitepace_from_values - removes leading/trailing whitespace from values
|
156
|
+
|
157
|
+
## 1.0.2 (2012-08-02)
|
158
|
+
|
159
|
+
* added more options for dealing with headers:
|
160
|
+
* :user_provided_headers ,user provided Array with header strings or symbols, to precisely define what the headers should be, overriding any in-file headers (default: nil)
|
161
|
+
* :headers_in_file , if the file contains headers as the first line (default: true)
|
162
|
+
|
163
|
+
## 1.0.1 (2012-07-30)
|
164
|
+
|
165
|
+
* added the following options:
|
166
|
+
* :downcase_header
|
167
|
+
* :strings_as_keys
|
168
|
+
* :remove_zero_values
|
169
|
+
* :remove_values_matching
|
170
|
+
* :remove_empty_hashes
|
171
|
+
* :convert_values_to_numeric
|
172
|
+
|
173
|
+
* renamed the following options:
|
174
|
+
* :remove_empty_fields => :remove_empty_values
|
175
|
+
|
176
|
+
|
177
|
+
## 1.0.0 (2012-07-29)
|
178
|
+
|
179
|
+
* renamed `SmarterCSV.process_csv` to `SmarterCSV.process`.
|
180
|
+
|
181
|
+
## 1.0.0.pre1 (2012-07-29)
|
data/CONTRIBUTORS.md
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
# A Big Thank You to all the Contributors!!
|
2
|
+
|
3
|
+
|
4
|
+
A Big Thank you to everyone who filed issues, sent comments, and who contributed with pull requests:
|
5
|
+
|
6
|
+
* [Jack 0](https://github.com/xjlin0)
|
7
|
+
* [Alejandro](https://github.com/agaviria)
|
8
|
+
* [Lucas Camargo de Almeida](https://github.com/lcalmeida)
|
9
|
+
* [Raphaël Bleuse](https://github.com/bleuse)
|
10
|
+
* [feens](https://github.com/feens)
|
11
|
+
* [César Camacho](https://github.com/chanko)
|
12
|
+
* [innhyu](https://github.com/innhyu)
|
13
|
+
* [Benjamin Thouret](https://github.com/benichu)
|
14
|
+
* [Chris Hilton](https://github.com/chrismhilton)
|
15
|
+
* [Sean Duckett](http://github.com/sduckett)
|
16
|
+
* [Alex Ong](http://github.com/khaong)
|
17
|
+
* [Martin Nilsson](http://github.com/MrTin)
|
18
|
+
* [Eustáquio Rangel](http://github.com/taq)
|
19
|
+
* [Pavel](http://github.com/paxa)
|
20
|
+
* [Félix Bellanger](https://github.com/Keeguon)
|
21
|
+
* [Graham Wetzler](https://github.com/grahamwetzler)
|
22
|
+
* [Marcos G. Zimmermann](https://github.com/marcosgz)
|
23
|
+
* [Jordan Running](https://github.com/jrunning)
|
24
|
+
* [Dave Sanders](https://github.com/DaveSanders)
|
25
|
+
* [Hugo Lepetit](https://github.com/giglemad)
|
26
|
+
* [esBeee](https://github.com/esBeee)
|
27
|
+
* [Waldyr de Souza](https://github.com/waldyr)
|
28
|
+
* [Ben Maher](https://github.com/benmaher)
|
29
|
+
* [Wal McConnell](https://github.com/wal)
|
30
|
+
* [Jordan Graft](https://github.com/jordangraft)
|
31
|
+
* [Michael](https://github.com/polycarpou)
|
32
|
+
* [Kevin Coleman](https://github.com/KevinColemanInc)
|
33
|
+
* [Tirdad C.](https://github.com/tridadc)
|
34
|
+
* [Dave Myron](https://github.com/contentfree)
|
35
|
+
* [Ivan Ushakov](https://github.com/IvanUshakov)
|
36
|
+
* [Matthieu Paret](https://github.com/mtparet)
|
37
|
+
* [Rohit Amarnath](https://github.com/ramarnat)
|
38
|
+
* [Joshua Smith](https://github.com/enviable)
|
39
|
+
* [Colin Petruno](https://github.com/colinpetruno)
|
40
|
+
* [Diego Salido](https://github.com/salidux)
|
41
|
+
* [Elie](https://github.com/elieteyssedou)
|
42
|
+
* [Chris Wong](https://github.com/lightwave)
|
43
|
+
* [Olle Jonsson](https://github.com/olleolleolle)
|
44
|
+
* [Nicolas Guillemain](https://github.com/Viiruus)
|
45
|
+
* [Sp6](https://github.com/sp6)
|
46
|
+
* [Joel Fouse](https://github.com/jfouse)
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2012..2022 Tilo Sloboda
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|