largeCsvProcessing 0.1.1 → 1.0.0

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
  SHA256:
3
- metadata.gz: 7cf435991f547c89c3cd230ac85bef8b91d581322a7aeef9bff36dc9155b2ee6
4
- data.tar.gz: 62f4b2382d94f4c120022ac3184297a175bf3ec58e38c31e68a4c4be8a915f53
3
+ metadata.gz: 425cc08c1c11ef8571b70538c2bbdc26e98a2c36b3298d8aa7b7d6488436bd15
4
+ data.tar.gz: 06e7e51da13fe817c2121761213c7dcf6284b4532e7a9c0addf3c1be925e9175
5
5
  SHA512:
6
- metadata.gz: c6fe106d452f9ba6fed7c7cf2cc8574302619eb19c43ff6a40e45b28fe3160ebe5fddf3fb77ade606d0cc22b1ef5fb4bb0b1ef7f3a6c6793a594284fd6b40f26
7
- data.tar.gz: d7ca7fc4c805f31200a36f9d29bc998d807a6ba6606d702730c7ab0de4aa5f1c2fae2aa605793c43c2774d30f5421858e09856163795b26f6ddf3bdb58a5f288
6
+ metadata.gz: dccddfdc5fa486692a7affea62548e389df3260b3524f15248ce4cc087a81ffb7968470a259789c70efcb36e827044ddd101d0ed5afd68300595403126ce3b92
7
+ data.tar.gz: c964b5139a675b2281ed13bdb7b3c296571aaf15d14243e07bf2a5d93ab586a498293e25cbf588e25bccf5f402d331520b08a2ef60c8b7104e3645e5b90cafdc
data/README.md CHANGED
@@ -1,17 +1,37 @@
1
- # -----------TAREA 1 LARGE CSV PROCESSING-----------!
1
+ # -----------( ENGLISH ) TASK 1 - LARGE CSV PROCESSING-----------!
2
2
 
3
- Escribir el script csv_generator.rb que tome como parámetro un número entero y genere un extracto en millones de filas. Por ejemplo si se ejecuta con parámetro 1 entonces el extracto tendrá 1 millones de filas + 1 por la cabecera.
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
- # FUNCIONAMIENTO Y OTROS DETALLES:
5
+ # OPERATION AND OTHER DETAILS:
6
6
 
7
- csv_generator.rb es un programa que consta de dos partes, cada parte está en las carpetas lector y extractor respectivamente los cuales describo a continuación:
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) A falta de un archivo lector para extraer contenido como pide esta tarea, creé un programa en la carpeta lector, el cual ingresando un número crea un archivo csv de registros con la cantidad ingresada multiplicado por 1_000_000. (se puede decir que este archivo lector.csv es una pseudotabla de la base de datos)
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) Ya con este archivo... Se ejecuta el programa extractor, el cual pide un segundo numero que se multiplicará por 1_000_000 y devolverá ese numero de filas extraidas del primer archivo. (este archivo extracto.csv extrae las filas solicitadas de la pseudotabla anteriormente creada)
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
- (Ambos programas se ejecutan automaticamente y secuencialmente)
13
+ # THIS EXERCISE BECAME A GEM!
14
14
 
15
- # ESTE EJERCICIO SE CONVIRTIÓ EN GEMA!
16
- para ejecutar la gema instalada se puede acceder por irb:
17
- require 'csv_generator'
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 './lector/lector'
1
+ require_relative './generatr/generator.rb'
2
2
 
3
- lecturaSemanal = Lector.new
4
- lecturaSemanal.nMillones = gets.chomp
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
- require_relative './extractor/extractor'
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.1.1
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-17 00:00:00.000000000 Z
11
+ date: 2022-05-20 00:00:00.000000000 Z
12
12
  dependencies: []
13
- description: Simple script that processes and extracts csv files from a much larger
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/extractor/extractor.rb
24
- - lib/lector/lector.rb
22
+ - lib/generatr/generator.rb
23
+ - readmeEs.txt
25
24
  homepage: https://github.com/duemarfra/largeCsvProcessing.git
26
25
  licenses:
27
26
  - MIT
@@ -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