-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlist_gen.py
More file actions
executable file
·55 lines (44 loc) · 1.41 KB
/
list_gen.py
File metadata and controls
executable file
·55 lines (44 loc) · 1.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/usr/bin/env python3
from pyexcel_ods3 import get_data, save_data
from collections import OrderedDict
# -------- Constantes
FILENAME_SRC = "listado_orig.ods"
FILENAME_TARGET = "listado-1.ods"
SHEET_TARGET = "Notas"
# --- Indices para la informacion en archivo fuente
CABECERA = 0
NOMBRE = 1
DNI = 2
MAT = 3
CONV = 4
#-- Nombre dado a la pestaña donde esta la informacion en
#-- el fichero fuente
SHEET_SRC = "archivo"
# -- Leer el fichero ods
data = get_data(FILENAME_SRC)
# -- Obtener los datos de la pestaña con los datos
sheet = data[SHEET_SRC]
# -- Crear una lista solo con los nombre
# -- En el original hay filas vacias
entry_src = [ row for row in sheet if row != [] ]
# -- Eliminar la primera fila (cabecera)
entry_src = entry_src[1:]
# -- Formato de la hoja destino
entry_dst = [["Mat", "Conv", "DNI", "Nombre"]]
# -- Leer la informacion de la hoja fuente
# -- y añadirla en la hoja destino
for estudiante in entry_src:
mat = estudiante[MAT]
conv = estudiante[CONV]
dni = estudiante[DNI]
name = estudiante[NOMBRE]
print(f"{mat} {conv} {dni} {name} ")
row_dst = [mat, conv, dni, name]
entry_dst.append(row_dst)
# -- Write the destination sheet
data_dst = OrderedDict()
data_dst.update({SHEET_TARGET: entry_dst})
save_data(FILENAME_TARGET, data_dst)
#-- Obtener el numero total de estudiantes
print(f"Estudiantes Totales: {len(entry_src)}\n")
print(f"Fichero de salida: {FILENAME_TARGET}\n")