quandl_data 1.3.5 → 1.3.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/UPGRADE.md +5 -0
- data/lib/quandl/data/cleaning.rb +4 -1
- data/lib/quandl/data/format.rb +9 -1
- data/lib/quandl/data/validations.rb +8 -4
- data/lib/quandl/data/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b9dbde1852003bcb9959d2fa89a19cbc9820f96d
|
4
|
+
data.tar.gz: bfe0bf490f623cb12ec2cb0fa967e85a5a3dbe5d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9d6a9e2268585f1ccf001cd14787d7fdf127822b458b03fa5132989337e0ca4aed5b3cf16e85dac2cfc28b44277e59c9ca67fc11dd84a712036d0791bdf49fa5
|
7
|
+
data.tar.gz: 4af620ee17de21560d716cccf78816c308530862065a16cd0cec5847d75b7a554ef1bc8e975ecd5dd047356c8375be199f3677ce968635a089a3d036e20ca78e
|
data/UPGRADE.md
CHANGED
data/lib/quandl/data/cleaning.rb
CHANGED
@@ -17,7 +17,7 @@ module Cleaning
|
|
17
17
|
def ensure_data_is_cleaned
|
18
18
|
data_array unless cleaned?
|
19
19
|
end
|
20
|
-
|
20
|
+
|
21
21
|
protected
|
22
22
|
|
23
23
|
def clean(data)
|
@@ -29,6 +29,9 @@ module Cleaning
|
|
29
29
|
data = ensure_data_is_an_array(data)
|
30
30
|
# clean with either format or babelfish
|
31
31
|
known_format?( data ) ? clean_with_format(data) : clean_with_babelfish(data)
|
32
|
+
# rescue clean_with_format failure and try with babelfish
|
33
|
+
# rescue
|
34
|
+
# clean_with_babelfish(data)
|
32
35
|
end
|
33
36
|
|
34
37
|
def ensure_data_requires_cleaning(data)
|
data/lib/quandl/data/format.rb
CHANGED
@@ -21,11 +21,19 @@ class Format
|
|
21
21
|
def csv_to_array(data)
|
22
22
|
if data.is_a?(String)
|
23
23
|
data = data.gsub('\n', "\n")
|
24
|
-
data = CSV.parse( data )
|
24
|
+
data = CSV.parse( data, {col_sep: guess_csv_delimiter(data) } )
|
25
25
|
end
|
26
26
|
data
|
27
27
|
end
|
28
28
|
|
29
|
+
def guess_csv_delimiter(data)
|
30
|
+
data = data.to_s
|
31
|
+
line_end = data.to_s.index("\n")
|
32
|
+
first_line = line_end.nil? ? data : data[0..line_end].to_s
|
33
|
+
return "\t" unless first_line.index("\t").nil?
|
34
|
+
","
|
35
|
+
end
|
36
|
+
|
29
37
|
def to_date(data)
|
30
38
|
return data if data_missing_rows?(data)
|
31
39
|
# guess the current date format
|
@@ -10,20 +10,24 @@ module Validations
|
|
10
10
|
|
11
11
|
included do
|
12
12
|
ERROR_TYPES = [
|
13
|
-
Error::GuessDateFormat,
|
13
|
+
Error::GuessDateFormat, Error::InvalidDate,
|
14
14
|
Error::UnknownDateFormat, Error::DateParseError ]
|
15
15
|
end
|
16
16
|
|
17
17
|
def valid?
|
18
|
-
|
19
|
-
self.data_array = pristine_data
|
20
|
-
true
|
18
|
+
raise_error_unless_valid!
|
21
19
|
rescue *ERROR_TYPES => error
|
22
20
|
self.errors << error
|
23
21
|
self.data_array = []
|
24
22
|
false
|
25
23
|
end
|
26
24
|
|
25
|
+
def raise_error_unless_valid!
|
26
|
+
self.errors = []
|
27
|
+
self.data_array = pristine_data
|
28
|
+
true
|
29
|
+
end
|
30
|
+
|
27
31
|
def errors
|
28
32
|
@errors ||= []
|
29
33
|
end
|
data/lib/quandl/data/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: quandl_data
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Blake Hilscher
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-12-
|
11
|
+
date: 2013-12-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: quandl_operation
|