loadmop 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d3202e7b2524ed515da693d766fd7eee7c77464d
4
- data.tar.gz: 4a8bc8d768d1a0c7ff6420c76a2f2b2eafecb9b0
3
+ metadata.gz: 0a7029b044d93f41028317ac778c8b24e75300a9
4
+ data.tar.gz: 54cfc07a3bb6728e92c943f34fa43b82cf4ddc2e
5
5
  SHA512:
6
- metadata.gz: 9314984cd3d57eca926764a3c9d16c596feb2c9d7c424468770e4d63fe26aafa95f3197be3f944bf138a80086dc78d112536ac1f976cf623d88441e0a6abd64d
7
- data.tar.gz: 919f29cee79ae79ec7a804f54a7bb2085d33de995bc32e311ce2247ed853ac2a93b310840c998ca8f7e5ce21271a9938623a8c84cdbedaad9450d992a8f99f56
6
+ metadata.gz: e7627ac22cb4226135881d79167176c2589daefdcb0e2ecbfe9f01f0cc66771c6c23c5515b53fcbf9265cc16a4482d0e40ed70e810247c2d762fbe881ededd29
7
+ data.tar.gz: 7edcd242425a3f20aeaef07f258c854fa3600139ece6037a0332e71a5485793dc14b385545cf4ab9cda3e876421cf98e878f47ecfff1b3ca296bb5012f8f5f41
data/CHANGELOG.md CHANGED
@@ -1,6 +1,21 @@
1
1
  # Changelog
2
2
  All notable changes to this project will be documented in this file.
3
3
 
4
+ ## 0.0.4 - 2014-08-29
5
+
6
+ ### Added
7
+ - Require database name as argument for each command.
8
+
9
+ ### Deprecated
10
+ - Nothing.
11
+
12
+ ### Removed
13
+ - Nothing.
14
+
15
+ ### Fixed
16
+ - #slow_load option was skipping rows and misreading headers.
17
+
18
+
4
19
  ## 0.0.3 - 2014-07-16
5
20
 
6
21
  ### Added
@@ -15,6 +30,7 @@ All notable changes to this project will be documented in this file.
15
30
  ### Fixed
16
31
  - Nothing.
17
32
 
33
+
18
34
  ## 0.0.2 - 2014-07-11
19
35
 
20
36
  ### Added
@@ -29,6 +45,7 @@ All notable changes to this project will be documented in this file.
29
45
  ### Fixed
30
46
  - Bug where schemas directory was not found when loadmop was installed as a gem
31
47
 
48
+
32
49
  ## 0.0.1 - 2014-07-10
33
50
 
34
51
  ### Added
data/README.md CHANGED
@@ -72,7 +72,7 @@ Then:
72
72
 
73
73
 
74
74
  ### Loading CDM Data
75
- - Run `bundle exec loadmop create_vocab_database /path/to/directory/holding/cdm/data/files`
75
+ - Run `bundle exec loadmop create_cdmv4_data /path/to/directory/holding/cdm/data/files`
76
76
  - This runs all the steps for loading CDM data into a database, namely
77
77
  - Creating the proper CDM tables
78
78
  - Prepping the CSV files to load into the database
data/lib/loadmop/cli.rb CHANGED
@@ -10,16 +10,16 @@ module Loadmop
10
10
  aliases: :s,
11
11
  desc: 'schema for database (PostgreSQL only)'
12
12
 
13
- desc 'create_vocab_database vocab_files_dir', 'Connects to database specified in the .env file and loads the OMOP Vocabulary schema and data into it'
14
- def create_vocab_database(vocab_files_dir)
15
- loader = VocabLoader.new(vocab_files_dir, options)
13
+ desc 'create_vocab_database database_name vocab_files_dir', 'Creates the vocabulary tables in database_name and loads the OMOP Vocabulary data into them.'
14
+ def create_vocab_database(database_name, vocab_files_dir)
15
+ loader = VocabLoader.new(database_name, vocab_files_dir, options)
16
16
  loader.create_database
17
17
  end
18
18
 
19
- desc 'create_cdmv4_data data_dir', 'Creates a schema in a database for OMOP CDMv4 then loads data into it as specified by data_files_dir'
20
- def create_cdmv4_database(data_files_dir)
21
- cdm_loader = CDMv4Loader.new(data_files_dir, options)
22
- cdm_loader.create_database
19
+ desc 'create_cdmv4_database database_name data_dir', 'Creates a set of tables in database_name for OMOP CDMv4 then loads data into them as specified by data_files_dir.'
20
+ def create_cdmv4_database(database_name, data_files_dir)
21
+ loader = CDMv4Loader.new(database_name, data_files_dir, options)
22
+ loader.create_database
23
23
  end
24
24
  end
25
25
  end
@@ -8,11 +8,11 @@ module Loadmop
8
8
 
9
9
  attr :options, :data_files_dir, :headers
10
10
 
11
- def initialize(data_files_dir, options = {})
11
+ def initialize(database_name, data_files_dir, options = {})
12
12
  @data_files_dir = Pathname.new(data_files_dir)
13
13
  @options = options
14
14
  @headers = {}
15
- db(options)
15
+ db(options.merge(database: database_name))
16
16
  end
17
17
 
18
18
  def create_database
@@ -100,10 +100,10 @@ module Loadmop
100
100
  all_files.each do |table_name, files|
101
101
  files.each do |file|
102
102
  puts "Loading #{file} into #{table_name}"
103
- CSV.open(file, headers: true) do |csv|
103
+ CSV.open(file) do |csv|
104
104
  csv.each_slice(1000) do |rows|
105
105
  print '.'
106
- db[table_name].import(headers_for(file), rows.map(&:fields))
106
+ db[table_name].import(headers_for(file), rows)
107
107
  end
108
108
  end
109
109
  puts
@@ -120,6 +120,9 @@ module Loadmop
120
120
  end
121
121
 
122
122
  def headers_for(file)
123
+ if file.to_s =~ /split/
124
+ file = Pathname.new(file.dirname.to_s.sub('split', 'cleaned') + '.csv')
125
+ end
123
126
  header_line = File.open(file, &:readline).downcase.gsub(/\|$/, '')
124
127
  CSV.parse(header_line).first.map(&:to_sym)
125
128
  end
@@ -1,3 +1,3 @@
1
1
  module Loadmop
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: loadmop
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Duryea
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-07-16 00:00:00.000000000 Z
11
+ date: 2014-08-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler