splitcsv 0.1 → 0.1.1

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: be264547c2670b48112abedbd4ff8fff12250f6c
4
- data.tar.gz: 74e41c1e85f4bada021ead17ef6b9e1624c0c49b
3
+ metadata.gz: 918a37b1e8e6b007e6983d5eef55563c76630ecb
4
+ data.tar.gz: 962ab87ce829fda71ba4caa929635d719fbf9483
5
5
  SHA512:
6
- metadata.gz: 419f4e1e1298ba6cbb8bf649621d1fb70fa03e5c6da257bda632082c1b1399f6a2c36ec4724ac4935c341d9d6d2c36f10a53a239d49c1fc760a478fca57184fd
7
- data.tar.gz: bfc707eb7e8409a334975f1f1f86ca314ad7fd0afb021cfae54c6b75ac3b4cbcf3faa4f47a426d598a5e65ac71521058c61f75b4e902c868a9e6f04d8ff72f60
6
+ metadata.gz: 5c6c0b2dab6ee0cc54715b879a25a505e565429ca4181f3d3ad5f341c5fa3c9971551da8269e426cc3fa1d2446003ff910d8b2c222f320cc9a9d8855b9d43081
7
+ data.tar.gz: 44e21aacd04250d4c48918412eee8a9f3b9fff77ba3277d97e297f9def85e8048ef05c090c33618b6fce58f207498b22e84c814b0c1f9dd24839207a10297ca2
data/bin/splitcsv CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require 'splitcsv'
3
+ require 'splitcsv/splitter'
4
4
 
5
5
  if (ARGV[0] == nil)
6
6
  puts 'Usage: splitcsv <file> [<maxlength> [<separator>]]'
@@ -15,5 +15,5 @@ end
15
15
  csv_maxlength = ARGV[1] || 5000
16
16
  csv_colseparator = ARGV[2] || ";"
17
17
 
18
- splitter = SplitCSV::SplitCSV.new
19
- splitter.split(ARGV[0], csv_maxlength, csv_colseparator)
18
+ my_splitter = SplitCSV::Splitter.new
19
+ my_splitter.split(ARGV[0], csv_maxlength, csv_colseparator)
@@ -1,3 +1,3 @@
1
1
  module Splitcsv
2
- VERSION = "0.1"
2
+ VERSION = "0.1.1"
3
3
  end
data/lib/splitcsv.rb CHANGED
@@ -1,31 +1,6 @@
1
1
  require "splitcsv/version"
2
+ require "splitcsv/splitter"
2
3
 
3
4
  module SplitCSV
4
- class SplitCSV
5
- def split(file, maxlength=5000, separator=';')
6
- csv_basename = File.basename(file, ".*")
7
- csv_path = File.expand_path(file)
8
- csv_dir = File.dirname(csv_path)
9
5
 
10
- csv_file = CSV.open(file, :row_sep => :auto, :col_sep => separator)
11
- csv_length = csv_file.readlines.size
12
-
13
- # Opnieuw inlezen zodat readline pointer terug aan 0 staat. Na gebruiken van
14
- # csv_file.readlines.size werd "csv_file" al eens volledig doorlopen
15
- csv_file = CSV.open(file, :row_sep => :auto, :col_sep => separator)
16
- firstline = csv_file.readline
17
-
18
- for i in 0..((csv_length / maxlength.to_i).ceil) do
19
- CSV.open("#{csv_dir}/#{csv_basename}_#{i+1}.csv", 'w', :row_sep => :auto, :col_sep => separator) do |csv|
20
- csv << firstline
21
-
22
- for j in 1..csv_maxlength do
23
- if (line = csv_file.readline) != nil
24
- csv << line
25
- end
26
- end
27
- end
28
- end
29
- end
30
- end
31
6
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: splitcsv
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.1'
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bert Devriese