panda.py 738 Bytes
import sop.config as config
import pandas as pd


class panda:
    def __init__(self) -> None:
        self.df = pd.read_excel(config.Ecxel)
        #print(self.df)
        self.largo = len(self.df)
        self.ultimo = self.largo - 1
        a = self.df.iloc[[0]].to_dict()
        self.Keys = a.keys()  
    

    def test(self):
        a = self.df.iloc[[0]]  
        d = a.to_dict()
        print(d.keys())

    def Leer(self,row=0):
        a = self.df.iloc[[row]]  
        d = a.to_dict()
        res = {"Row":row}
        for key in self.Keys:
            dat = d[key]
            if str(dat[row]) in ["S/D","NaN","nan"]:
                res[key] = False
            else:
                res[key] = dat[row]
        return(res)