Skip to content

Commit

Permalink
Añadd Test Back-End
Browse files Browse the repository at this point in the history
  • Loading branch information
oderay97 committed Sep 23, 2022
1 parent 0db0f31 commit f2791e5
Show file tree
Hide file tree
Showing 11 changed files with 554 additions and 0 deletions.
8 changes: 8 additions & 0 deletions Test_Back_end_Pythonk/.spyproject/config/codestyle.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[codestyle]
indentation = True
edge_line = True
edge_line_columns = 79

[main]
version = 0.2.0

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[codestyle]
indentation = True
edge_line = True
edge_line_columns = 79

Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[encoding]
text_encoding = utf-8

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[vcs]
use_version_control = False
version_control_system =

Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[workspace]
restore_data_on_startup = True
save_data_on_exit = True
save_history = True
save_non_project_files = False

6 changes: 6 additions & 0 deletions Test_Back_end_Pythonk/.spyproject/config/encoding.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[encoding]
text_encoding = utf-8

[main]
version = 0.2.0

7 changes: 7 additions & 0 deletions Test_Back_end_Pythonk/.spyproject/config/vcs.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[vcs]
use_version_control = False
version_control_system =

[main]
version = 0.2.0

12 changes: 12 additions & 0 deletions Test_Back_end_Pythonk/.spyproject/config/workspace.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[workspace]
restore_data_on_startup = True
save_data_on_exit = True
save_history = True
save_non_project_files = False
project_type = 'empty-project-type'
recent_files = []

[main]
version = 0.2.0
recent_files = []

84 changes: 84 additions & 0 deletions Test_Back_end_Pythonk/app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
# -*- coding: utf-8 -*-
"""
Created on Tue Sep 20 21:18:16 2022
"""


import pandas as pd
import numpy as np
from collections import defaultdict


m = pd.read_excel("file.xlsx", header=None).to_numpy()

# =============================================================================
# La clase SpreadsheetConverter traduce una celda con la forma 'A1' a una
# coordenada de matriz m[0][0]
# =============================================================================

class SpreadsheetConverter(object):

def __init__(self, m:np.array, cell_ref:str):

self.m = m # matriz con máximo 26 "columnas"
self.cell_ref = cell_ref # celda con forma 'A1'


def array_coord(self) -> str:
r1 = self.to_cols()
r2 = self.to_rows()

r ="m[{}][{}]".format(r2, r1)

return r

def array_query(self) -> str:
r1 = self.to_cols()
r2 = self.to_rows()

r = m[r2][r1]

return r


@classmethod
def to_rows(self) -> int :
dict1 = defaultdict(dict)
for i in range(m.shape[0]):
dict1[i] = i - 1


row = dict1[int(cell_ref[1:])]

return row

@classmethod
def to_cols(self) -> int:
dict2 = {'A':0,'B':1,'C':2,'D':3,'E':4,'F':5,
'G':6,'H':7,'I':8,'J':9,'K':10,'L':11,
'M':12,'N':13,'O':14,'P':15,'Q':16,'R':17,
'S':18,'T':19,'U':20, 'V':21,'W':22,'X':23,
'Y':24,'Z':25}

col = dict2[cell_ref[0].upper()]

return col


##############################################################################

cell_ref = "Z25"
sc = SpreadsheetConverter(m, cell_ref)

sc.array_coord()
sc.array_query()









Binary file added Test_Back_end_Pythonk/file.xlsx
Binary file not shown.

0 comments on commit f2791e5

Please sign in to comment.