load the initial dataset into mongodb
This commit is contained in:
parent
38318281e9
commit
c72b69ef9f
|
@ -79,4 +79,5 @@ Y hacerlo de forma cooperativa, reuniendo esfuerzos y capacidades en torno a un
|
|||
- Jaime Gómez Obregón ([@JaimeObregon](https://twitter.com/jaimeobregon)), _scraping_ de los datos y propuesta inicial.
|
||||
- JuanMa Cuevas ([@juanmacuevas](https://twitter.com/juanmacuevas)), programador python & android. _hacktivista_ aficionado.
|
||||
- Yago F. ([@yaguetoo](https://github.com/yagueto)), programador Python y Java.
|
||||
- Pedro J. Molina ([@pjmolina](https://github.com/phmolina)), programador TypeScript, Docker y dotNet.
|
||||
- …
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
# Ignore data files here
|
||||
*.gz
|
|
@ -0,0 +1,11 @@
|
|||
## Seed database
|
||||
|
||||
FROM mongo:5.0.6-focal
|
||||
WORKDIR /app/data
|
||||
COPY data/* .
|
||||
COPY script.sh .
|
||||
RUN chmod +x script.sh
|
||||
|
||||
ENV HOST=mongodb
|
||||
|
||||
CMD ["/app/data/script.sh"]
|
|
@ -0,0 +1,14 @@
|
|||
# Scripts para cargar en MongoDB
|
||||
|
||||
Scripts para carga de datos desde CSV en una base de datos MongoDB con docker.
|
||||
|
||||
## Prerrequisitos
|
||||
|
||||
- bash
|
||||
- Docker
|
||||
|
||||
## Como usarlo
|
||||
|
||||
```bash
|
||||
./docker-build.sh
|
||||
```
|
|
@ -0,0 +1,14 @@
|
|||
# Load Scripts for MongoDB
|
||||
|
||||
Data load Scripts for MongoDB database.
|
||||
|
||||
## Prerequirements
|
||||
|
||||
- bash
|
||||
- Docker
|
||||
|
||||
## How to use it
|
||||
|
||||
```bash
|
||||
./docker-build.sh
|
||||
```
|
|
@ -0,0 +1 @@
|
|||
id, codigo_bdns, MRR, administracion, departamento, organo, fecha_registro, titulo_convocatoria, url_bases_regul, titulo_cooficial, colDesconocida1, colDesconocida2, colDesconocida3
|
|
|
@ -0,0 +1 @@
|
|||
id, id_convocatoria, administracion, departamento, organo, titulo_convocatoria, url_bases_regul, apli_presupuestaria, fecha_concesion, beneficiario, importe, instrumento, ayuda_equivalente, detalles, codigo_bdns, valor_desconocido, id_interna
|
|
|
@ -0,0 +1,16 @@
|
|||
#!/bin/sh
|
||||
# Create an initial DB in mongodb from CSV files
|
||||
|
||||
PORT=27017
|
||||
|
||||
cp ../../files/*.csv.gz ./data/
|
||||
docker build -t mongo-seed -f Dockerfile-seed .
|
||||
|
||||
|
||||
docker rm mongo-sub mongo-seed -f
|
||||
|
||||
docker run --name mongo-sub -d -p $PORT:27017 mongo:5.0.6-focal
|
||||
|
||||
docker run --link mongo-sub:mongodb --name mongo-seed mongo-seed
|
||||
|
||||
echo "Done. DB ready listening at $PORT!"
|
|
@ -0,0 +1,27 @@
|
|||
#!/bin/sh
|
||||
# Import data
|
||||
|
||||
HOST=mongodb
|
||||
|
||||
echo "$(date -u) Import started" > status
|
||||
|
||||
gzip -d convocatorias.csv.gz
|
||||
gzip -d juridicas_1.csv.gz
|
||||
gzip -d juridicas_2.csv.gz
|
||||
|
||||
cp convocatorias-headers.csv c1.csv
|
||||
cp juridicas-headers.csv j1.csv
|
||||
cp juridicas-headers.csv j2.csv
|
||||
|
||||
cat convocatorias.csv >> c1.csv
|
||||
cat juridicas_1.csv >> j1.csv
|
||||
cat juridicas_2.csv >> j2.csv
|
||||
|
||||
|
||||
mongoimport --host $HOST --type csv -d subvenciones -c convocatorias --headerline --drop c1.csv
|
||||
mongoimport --host $HOST --type csv -d subvenciones -c juridicas --headerline --drop j1.csv
|
||||
mongoimport --host $HOST --type csv -d subvenciones -c juridicas --headerline j2.csv
|
||||
|
||||
rm *.csv
|
||||
|
||||
echo "$(date -u) Import done!" >> status
|
Loading…
Reference in New Issue