largeCsvProcessing 0.1.1 → 1.0.0
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.
- checksums.yaml +4 -4
- data/README.md +30 -10
- data/lib/csv_generator.rb +6 -10
- data/lib/generatr/generator.rb +30 -0
- data/readmeEs.txt +37 -0
- metadata +5 -6
- data/lib/extractor/extractor.rb +0 -25
- data/lib/lector/lector.rb +0 -34
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 425cc08c1c11ef8571b70538c2bbdc26e98a2c36b3298d8aa7b7d6488436bd15
|
4
|
+
data.tar.gz: 06e7e51da13fe817c2121761213c7dcf6284b4532e7a9c0addf3c1be925e9175
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dccddfdc5fa486692a7affea62548e389df3260b3524f15248ce4cc087a81ffb7968470a259789c70efcb36e827044ddd101d0ed5afd68300595403126ce3b92
|
7
|
+
data.tar.gz: c964b5139a675b2281ed13bdb7b3c296571aaf15d14243e07bf2a5d93ab586a498293e25cbf588e25bccf5f402d331520b08a2ef60c8b7104e3645e5b90cafdc
|
data/README.md
CHANGED
@@ -1,17 +1,37 @@
|
|
1
|
-
# -----------
|
1
|
+
# -----------( ENGLISH ) TASK 1 - LARGE CSV PROCESSING-----------!
|
2
2
|
|
3
|
-
|
3
|
+
Write the csv_generator.rb script that takes an integer as a parameter and generates an extract in millions of rows. For example, if it is executed with parameter 1, then the extract will have 1 million rows + 1 for the header.
|
4
4
|
|
5
|
-
#
|
5
|
+
# OPERATION AND OTHER DETAILS:
|
6
6
|
|
7
|
-
csv_generator.rb
|
7
|
+
1. csv_generator.rb: it is the main program in which an object is created based on the class located in ./generatr/generator.rb
|
8
8
|
|
9
|
-
1
|
9
|
+
1.1 generator.rb: contains the Generator class, its variables are an input digit, the header and its 4 books. It also contains a "newFile" method which multiplies the input by a million and creates a file.csv by writing the header and so many million books to it.
|
10
10
|
|
11
|
-
2
|
11
|
+
2. file.csv: In the first line is the header and in the following there will be as many millions of books as the input data says.
|
12
12
|
|
13
|
-
|
13
|
+
# THIS EXERCISE BECAME A GEM!
|
14
14
|
|
15
|
-
|
16
|
-
|
17
|
-
|
15
|
+
With the following command the gem was built:
|
16
|
+
gem build largeCsvProcessing.gemspec
|
17
|
+
|
18
|
+
The following command is used to install the gem locally:
|
19
|
+
gem install ./largeCsvProcessing-1.0.0.gem
|
20
|
+
|
21
|
+
The following command is used to install the gem remotely:
|
22
|
+
gem install largeCsvProcessing
|
23
|
+
|
24
|
+
The following command is used to uninstall the gem:
|
25
|
+
gem uninstall largeCsvProcessing
|
26
|
+
|
27
|
+
The following command is used to publish the gem to rubygems:
|
28
|
+
gem push largeCsvProcessing-1.0.0.gem
|
29
|
+
|
30
|
+
To run the installed gem it can be accessed by irb:
|
31
|
+
require 'csv_generator'
|
32
|
+
|
33
|
+
# BIBLIOGRAPHY
|
34
|
+
|
35
|
+
https://rubygems.org/?locale=es
|
36
|
+
|
37
|
+
https://blog.desafiolatam.com/crear-una-gema-ruby/
|
data/lib/csv_generator.rb
CHANGED
@@ -1,12 +1,8 @@
|
|
1
|
-
require_relative './
|
1
|
+
require_relative './generatr/generator.rb'
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
lecturaSemanal.nuevaLectura
|
3
|
+
puts 'How many millions of books do you want?? (give me the number)'
|
4
|
+
puts 'Example: 27 make a file.csv of 1GB, 432 make a file.csv of 16GB'
|
6
5
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
extracto = Extractor.new
|
11
|
-
extracto.nMillones = gets.chomp
|
12
|
-
extracto.nuevoExtracto
|
6
|
+
lecturaSemanal = Generator.new
|
7
|
+
lecturaSemanal.millions = gets.chomp
|
8
|
+
lecturaSemanal.newFile
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'csv'
|
2
|
+
|
3
|
+
class Generator
|
4
|
+
|
5
|
+
attr_accessor :millions
|
6
|
+
|
7
|
+
@@cabecera = '"Date","ISBN","Amount"'
|
8
|
+
|
9
|
+
book1 = '"2008-04-12","978-1-9343561-0-4",39.45'
|
10
|
+
book2 = '"2008-04-13","978-1-9343561-6-6",45.67'
|
11
|
+
book3 = '"2008-04-14","978-1-9343560-7-4",36.95'
|
12
|
+
book4 = '"2008-04-15","978-1-9343560-9-9",40.69'
|
13
|
+
|
14
|
+
@@allBooks = book1+"\n"+book2+"\n"+book3+"\n"+book4+"\n"
|
15
|
+
|
16
|
+
def newFile
|
17
|
+
|
18
|
+
File.open( './file.csv', 'a' ) { |row| row.write @@cabecera+"\n" }
|
19
|
+
|
20
|
+
nRepeticiones = 1_000_000 * @millions.to_i / 4
|
21
|
+
|
22
|
+
nRepeticiones.times {
|
23
|
+
|
24
|
+
File.open( './file.csv', 'a' ) { |row| row.write @@allBooks }
|
25
|
+
|
26
|
+
}
|
27
|
+
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
data/readmeEs.txt
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
# -----------( ESPAÑOL ) TAREA 1 - LARGE CSV PROCESSING-----------!
|
2
|
+
|
3
|
+
Write the csv_generator.rb script that takes an integer as a parameter and generates an extract in millions of rows. For example, if it is executed with parameter 1, then the extract will have 1 million rows + 1 for the header.
|
4
|
+
|
5
|
+
# FUNCIONAMIENTO Y OTROS DETALLES:
|
6
|
+
|
7
|
+
1. csv_generator.rb: es es el programa principal en el cual se crea un objeto en base la clase ubicada en ./generatr/generator.rb
|
8
|
+
|
9
|
+
1.1 generator.rb: contiene la clase Generator, sus variables son un digito de entrada, la cabecera y sus 4 libros. Tambien contiene un método "newFile" el cual multiplica el dato de entrada por un millon y crea un archivo file.csv escribiendo en él, la cabecera y tantos millones de libros.
|
10
|
+
|
11
|
+
2. file.csv: En la primera linea se encuantra la cabecera y en las siguientes habrá tantos millones de libros como el dato de entrada lo diga.
|
12
|
+
|
13
|
+
# ESTE EJERCICIO SE CONVIRTIÓ EN GEMA!
|
14
|
+
|
15
|
+
Con el siguiente comando se construyó la gema:
|
16
|
+
gem build largeCsvProcessing.gemspec
|
17
|
+
|
18
|
+
El siguiente comando sirve para instalar la gema de manera local:
|
19
|
+
gem install ./largeCsvProcessing-1.0.0.gem
|
20
|
+
|
21
|
+
El siguiente comando sirve para instalar la gema de manera remota:
|
22
|
+
gem install largeCsvProcessing
|
23
|
+
|
24
|
+
El siguiente comando sirve para desinstalar la gema:
|
25
|
+
gem uninstall largeCsvProcessing
|
26
|
+
|
27
|
+
El siguiente comando sirve para publicar la gema en rubygems:
|
28
|
+
gem push largeCsvProcessing-1.0.0.gem
|
29
|
+
|
30
|
+
Para ejecutar la gema instalada se puede acceder por irb:
|
31
|
+
require 'csv_generator'
|
32
|
+
|
33
|
+
# BIBLIOGRAFÍA
|
34
|
+
|
35
|
+
https://rubygems.org/?locale=es
|
36
|
+
|
37
|
+
https://blog.desafiolatam.com/crear-una-gema-ruby/
|
metadata
CHANGED
@@ -1,17 +1,16 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: largeCsvProcessing
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Marcelo Dueñas
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-05-
|
11
|
+
date: 2022-05-20 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
|
-
description: Simple script that
|
14
|
-
file
|
13
|
+
description: Simple script that make a file.csv with books non editable in yurs rows
|
15
14
|
email: duemarfra@gmail.com
|
16
15
|
executables: []
|
17
16
|
extensions: []
|
@@ -20,8 +19,8 @@ files:
|
|
20
19
|
- LICENSE
|
21
20
|
- README.md
|
22
21
|
- lib/csv_generator.rb
|
23
|
-
- lib/
|
24
|
-
-
|
22
|
+
- lib/generatr/generator.rb
|
23
|
+
- readmeEs.txt
|
25
24
|
homepage: https://github.com/duemarfra/largeCsvProcessing.git
|
26
25
|
licenses:
|
27
26
|
- MIT
|
data/lib/extractor/extractor.rb
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
require 'csv'
|
2
|
-
|
3
|
-
puts '***Este es el programa que crea un archivo de EXTRACTO, extrae tantos millones del archivo de lectura original segun queramos***'
|
4
|
-
puts 'INGRESE UN NUMERO Y OBTENDRA UN ARCHIVO CSV MUTIPLICADO POR MILLONES DE DICHO NUMERO (tiene que ser igual o menor que la lectura original)'
|
5
|
-
|
6
|
-
class Extractor
|
7
|
-
|
8
|
-
attr_accessor :nMillones
|
9
|
-
@@libros = CSV.read('./lector.csv').map
|
10
|
-
@@espacio = "\n"
|
11
|
-
|
12
|
-
def nuevoExtracto
|
13
|
-
|
14
|
-
nRepeticiones = ( @nMillones.to_i * 1_000_000 ) + 1
|
15
|
-
|
16
|
-
nRepeticiones.times {
|
17
|
-
|
18
|
-
File.open( './extracto.csv', 'a' ) { |row| row.write @@libros.next}
|
19
|
-
File.open( './extracto.csv', 'a' ) { |row| row.write @@espacio}
|
20
|
-
|
21
|
-
}
|
22
|
-
|
23
|
-
end
|
24
|
-
|
25
|
-
end
|
data/lib/lector/lector.rb
DELETED
@@ -1,34 +0,0 @@
|
|
1
|
-
require 'csv'
|
2
|
-
|
3
|
-
puts '***Este es el programa que crea el archivo del control físico semanal de todos los libros del depósito***'
|
4
|
-
puts 'INGRESE UN NUMERO Y OBTENDRA UN ARCHIVO CSV MUTIPLICADO POR MILLONES DE DICHO NUMERO'
|
5
|
-
|
6
|
-
class Lector
|
7
|
-
|
8
|
-
attr_accessor :nMillones
|
9
|
-
@@cabecera = '"Date","ISBN","Amount"'
|
10
|
-
@@book1 = '"2008-04-12","978-1-9343561-0-4",39.45'
|
11
|
-
@@book2 = '"2008-04-13","978-1-9343561-6-6",45.67'
|
12
|
-
@@book3 = '"2008-04-14","978-1-9343560-7-4",36.95'
|
13
|
-
@@book4 = '"2008-04-15","978-1-9343560-9-9",40.69'
|
14
|
-
@@espacio = "\n"
|
15
|
-
|
16
|
-
def nuevaLectura
|
17
|
-
|
18
|
-
File.open( './lector.csv', 'a' ) { |file| file.write @@cabecera+@@espacio }
|
19
|
-
|
20
|
-
nRepeticiones = 1_000_000 * @nMillones.to_i / 4
|
21
|
-
|
22
|
-
|
23
|
-
nRepeticiones.times {
|
24
|
-
|
25
|
-
File.open( './lector.csv', 'a' ) { |file| file.write @@book1+@@espacio }
|
26
|
-
File.open( './lector.csv', 'a' ) { |file| file.write @@book2+@@espacio }
|
27
|
-
File.open( './lector.csv', 'a' ) { |file| file.write @@book3+@@espacio }
|
28
|
-
File.open( './lector.csv', 'a' ) { |file| file.write @@book4+@@espacio }
|
29
|
-
|
30
|
-
}
|
31
|
-
|
32
|
-
end
|
33
|
-
|
34
|
-
end
|