first commit
This commit is contained in:
36
videotron1.py
Normal file
36
videotron1.py
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
import pandas as pd
|
||||||
|
import PySimpleGUI as sg
|
||||||
|
sg.theme("Brownblue")
|
||||||
|
layout = [[sg.T("")], [sg.Text("Choisir le fichier CSV: "), sg.Input(key="-IN2-" ,change_submits=True), sg.FileBrowse(key="-IN-")],[sg.Button("Submit")]]
|
||||||
|
|
||||||
|
window = sg.Window('VIDEOTRON MOBILE DATA CALCULATOR', layout, size=(600,150))
|
||||||
|
|
||||||
|
|
||||||
|
while True:
|
||||||
|
event, values = window.read()
|
||||||
|
|
||||||
|
if event == sg.WIN_CLOSED or event=="Exit":
|
||||||
|
break
|
||||||
|
elif event == "Submit":
|
||||||
|
pd.set_option('display.max_rows', None)
|
||||||
|
|
||||||
|
df = pd.read_csv(values["-IN2-"], sep=";", encoding='unicode_escape', decimal=",", usecols=[9,20,39])
|
||||||
|
|
||||||
|
df.replace('UTILISATION POUR LE', '', regex=True, inplace=True)
|
||||||
|
|
||||||
|
df = df.set_axis(['USER', 'B', 'DATA'], axis=1)
|
||||||
|
df = df.replace('é', 'e', regex=True)
|
||||||
|
df = df.replace('Ã', 'E', regex=True)
|
||||||
|
df = df.replace('E´', 'o', regex=True)
|
||||||
|
df = df.replace('E§', 'c', regex=True)
|
||||||
|
df = df.replace('', '', regex=True)
|
||||||
|
|
||||||
|
df = df[df['B'].str.contains('DONN')]
|
||||||
|
|
||||||
|
df['DATA'] = df['DATA'].apply(lambda x: float(x.split()[0].replace(',', '.')))
|
||||||
|
|
||||||
|
datasum = df.groupby('USER')['DATA'].sum(min_count=1).reset_index()
|
||||||
|
|
||||||
|
print(datasum)
|
||||||
|
|
||||||
|
|
||||||
45
videotron2.py
Normal file
45
videotron2.py
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
import PySimpleGUI as sg
|
||||||
|
import pandas as pd
|
||||||
|
|
||||||
|
file_list_column = [
|
||||||
|
[sg.Text('Choose CSV File')],
|
||||||
|
[sg.Text('File Location: '), sg.Input(size=(25, 1), key="-IN2-",
|
||||||
|
change_submits=True), sg.FileBrowse(key="-IN-")],
|
||||||
|
[sg.Button('Submit')],
|
||||||
|
[sg.Output(size=(60, 40))]]
|
||||||
|
|
||||||
|
layout = [[(file_list_column)]]
|
||||||
|
|
||||||
|
window = sg.Window('VIDEOTRON DATA CALCULATOR', layout)
|
||||||
|
|
||||||
|
while True:
|
||||||
|
event, values = window.read()
|
||||||
|
|
||||||
|
if event == sg.WIN_CLOSED or event == "Exit":
|
||||||
|
break
|
||||||
|
|
||||||
|
if event == 'Submit':
|
||||||
|
|
||||||
|
pd.set_option('display.max_rows', None)
|
||||||
|
|
||||||
|
df = pd.read_csv(
|
||||||
|
values["-IN2-"], sep=";", encoding='unicode_escape', decimal=",", usecols=[9, 20, 39])
|
||||||
|
|
||||||
|
df.replace('UTILISATION POUR LE', '', regex=True, inplace=True)
|
||||||
|
|
||||||
|
df = df.set_axis(['NOM', 'B', 'DATA'], axis=1)
|
||||||
|
|
||||||
|
df = df[df['B'].str.contains('DONN')]
|
||||||
|
|
||||||
|
df = df.replace('é', 'e', regex=True)
|
||||||
|
df = df.replace('Ã', 'E', regex=True)
|
||||||
|
df = df.replace('E´', 'o', regex=True)
|
||||||
|
df = df.replace('E§', 'c', regex=True)
|
||||||
|
df = df.replace('', '', regex=True)
|
||||||
|
|
||||||
|
df['DATA'] = df['DATA'].apply(
|
||||||
|
lambda x: float(x.split()[0].replace(',', '.')))
|
||||||
|
|
||||||
|
datasum = df.groupby('NOM')['DATA'].sum(min_count=1).reset_index()
|
||||||
|
|
||||||
|
print(datasum)
|
||||||
Reference in New Issue
Block a user