fix value nan/add view
This commit is contained in:
@ -1 +0,0 @@
|
|||||||
,pc-sviluppo1,pcsviluppo1,10.12.2024 10:17,file:///home/pc-sviluppo1/.config/libreoffice/4;
|
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -15,11 +15,13 @@ tla = 1
|
|||||||
value_insert = []
|
value_insert = []
|
||||||
def insert_records(connection,codice,descrizione,um,costo,sc1,sc2,ricarica,listino,codice_alternativo,codice_barre,art,tsa_codice):
|
def insert_records(connection,codice,descrizione,um,costo,sc1,sc2,ricarica,listino,codice_alternativo,codice_barre,art,tsa_codice):
|
||||||
try:
|
try:
|
||||||
|
print('tipo tsa_codice')
|
||||||
|
|
||||||
result = []
|
result = []
|
||||||
cursor = connection.cursor()
|
cursor = connection.cursor()
|
||||||
if art == False:
|
if art == False:
|
||||||
query_art = "INSERT INTO art (codice,DESCRIZIONE1,TUM_CODICE,codice_alternativo,TSA_CODICE,TUB_CODICE,TCM_CODICE,TGM_CODICE,TIV_CODICE_VENDITE,TIV_CODICE_ACQUISTI,TCA_CODICE,TAQ_CODICE,TS3_CODICE,TP2_CODICE,TIN_CODICE,TAA_CODICE) VALUES (%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)"
|
query_art = "INSERT INTO art (codice,DESCRIZIONE1,TUM_CODICE,codice_alternativo,TSA_CODICE,TUB_CODICE,TCM_CODICE,TGM_CODICE,TIV_CODICE_VENDITE,TIV_CODICE_ACQUISTI,TCA_CODICE,TAQ_CODICE,TS3_CODICE,TP2_CODICE,TIN_CODICE,TAA_CODICE,TNI_CODICE) VALUES (%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)"
|
||||||
cursor.execute(query_art,(codice,descrizione,um,codice_alternativo,tsa_codice,'0','0','0','22','22','0','0','0','0','0','0'))
|
cursor.execute(query_art,(codice,descrizione,um,codice_alternativo,tsa_codice,'0','0','0','22','22','0','0','0','0','0','0','0'))
|
||||||
count = cursor.rowcount
|
count = cursor.rowcount
|
||||||
result.append(count)
|
result.append(count)
|
||||||
|
|
||||||
@ -29,7 +31,6 @@ def insert_records(connection,codice,descrizione,um,costo,sc1,sc2,ricarica,listi
|
|||||||
result.append(count)
|
result.append(count)
|
||||||
|
|
||||||
if listino == 1:
|
if listino == 1:
|
||||||
print('listino è uno')
|
|
||||||
query_lsv = "INSERT INTO lsv (ART_CODICE,DATA_FINE,DATA_INIZIO,PREZZO,TSM_CODICE,TRL_CODICE,TLV_CODICE) VALUES (%s,%s,%s,%s,%s,%s,%s)"
|
query_lsv = "INSERT INTO lsv (ART_CODICE,DATA_FINE,DATA_INIZIO,PREZZO,TSM_CODICE,TRL_CODICE,TLV_CODICE) VALUES (%s,%s,%s,%s,%s,%s,%s)"
|
||||||
cursor.execute(query_lsv,(codice,data_fine,formatted_date,costo,sc2,ricarica,listino))
|
cursor.execute(query_lsv,(codice,data_fine,formatted_date,costo,sc2,ricarica,listino))
|
||||||
count = cursor.rowcount
|
count = cursor.rowcount
|
||||||
|
|||||||
17
main.py
17
main.py
@ -13,6 +13,7 @@ from update import update_records
|
|||||||
from insert import insert_records
|
from insert import insert_records
|
||||||
from write import write_excel
|
from write import write_excel
|
||||||
from write_excel_insert import write_excel_insert
|
from write_excel_insert import write_excel_insert
|
||||||
|
from upload import upload_excel
|
||||||
|
|
||||||
|
|
||||||
host = "62.86.98.170"
|
host = "62.86.98.170"
|
||||||
@ -24,7 +25,8 @@ port = 3307
|
|||||||
#creo la connessione al database
|
#creo la connessione al database
|
||||||
conn = create_connection(host, user, password, database, port)
|
conn = create_connection(host, user, password, database, port)
|
||||||
#leggo il file excel
|
#leggo il file excel
|
||||||
df = pd.read_excel('TEST.xlsx', usecols='A:N')
|
file_input = upload_excel()
|
||||||
|
df = pd.read_excel(file_input, usecols='A:N')
|
||||||
|
|
||||||
#leggo le colonne del file excel
|
#leggo le colonne del file excel
|
||||||
for index, row in df.iterrows():
|
for index, row in df.iterrows():
|
||||||
@ -32,6 +34,7 @@ for index, row in df.iterrows():
|
|||||||
descrizione = row['DESCRIZIONE']
|
descrizione = row['DESCRIZIONE']
|
||||||
um = row['UN']
|
um = row['UN']
|
||||||
costo = row['COSTO']
|
costo = row['COSTO']
|
||||||
|
|
||||||
|
|
||||||
if math.isnan(row['SC1']):
|
if math.isnan(row['SC1']):
|
||||||
sc1 = row['SC1']
|
sc1 = row['SC1']
|
||||||
@ -68,10 +71,12 @@ for index, row in df.iterrows():
|
|||||||
codice_alternativo = str(row['CODICE ALTERNATIVO'])
|
codice_alternativo = str(row['CODICE ALTERNATIVO'])
|
||||||
prezzo = float(row['COSTO'])
|
prezzo = float(row['COSTO'])
|
||||||
|
|
||||||
|
|
||||||
if math.isnan(row['TSA_CODICE']):
|
if math.isnan(row['TSA_CODICE']):
|
||||||
tsa_codice = row['TSA_CODICE']
|
tsa_codice = row['TSA_CODICE']
|
||||||
else:
|
else:
|
||||||
tsa_codice = int(row['TSA_CODICE'])
|
tsa_codice = int(row['TSA_CODICE'])
|
||||||
|
|
||||||
|
|
||||||
if conn :
|
if conn :
|
||||||
if ricarica1 is not None and not math.isnan(ricarica1):
|
if ricarica1 is not None and not math.isnan(ricarica1):
|
||||||
@ -95,7 +100,7 @@ for index, row in df.iterrows():
|
|||||||
if value_update is not None:
|
if value_update is not None:
|
||||||
write_excel(value_update)
|
write_excel(value_update)
|
||||||
else: ## se non esiste o non esiste con quel listino effettuo l'inserimento
|
else: ## se non esiste o non esiste con quel listino effettuo l'inserimento
|
||||||
costo = 0.00
|
##costo = 0.00
|
||||||
if descrizione is None :
|
if descrizione is None :
|
||||||
descrizione = ' '
|
descrizione = ' '
|
||||||
if um is None:
|
if um is None:
|
||||||
@ -106,12 +111,12 @@ for index, row in df.iterrows():
|
|||||||
sc2 = ' '
|
sc2 = ' '
|
||||||
if math.isnan(ricarica):
|
if math.isnan(ricarica):
|
||||||
ricarica = ' '
|
ricarica = ' '
|
||||||
if codice_alternativo is None:
|
if not pd.isna(codice_alternativo):
|
||||||
codice_alternativo = ' '
|
codice_alternativo = ' '
|
||||||
if codice_barre is None:
|
if not pd.isna(codice_barre):
|
||||||
codice_barre = ' '
|
codice_barre = '0000000000000'
|
||||||
if math.isnan(tsa_codice):
|
if math.isnan(tsa_codice):
|
||||||
tsa_codice = ' '
|
tsa_codice = '0'
|
||||||
|
|
||||||
value_insert = insert_records(conn,codice,descrizione,um,costo,sc1,sc2,ricarica,listino,codice_alternativo,codice_barre,art,tsa_codice)
|
value_insert = insert_records(conn,codice,descrizione,um,costo,sc1,sc2,ricarica,listino,codice_alternativo,codice_barre,art,tsa_codice)
|
||||||
write_excel_insert(value_insert)
|
write_excel_insert(value_insert)
|
||||||
|
|||||||
@ -73,7 +73,6 @@ def update_records(connection,codice,prezzo,sc1,sc2,listino,ricarica,codice_barr
|
|||||||
if math.isnan(ricarica):
|
if math.isnan(ricarica):
|
||||||
ricarica = 0
|
ricarica = 0
|
||||||
|
|
||||||
|
|
||||||
if math.isnan(codice_barre):
|
if math.isnan(codice_barre):
|
||||||
codice_barre = 0
|
codice_barre = 0
|
||||||
|
|
||||||
|
|||||||
17
upload.py
Normal file
17
upload.py
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
import pandas as pd
|
||||||
|
import mysql.connector
|
||||||
|
import math
|
||||||
|
import xlsxwriter
|
||||||
|
import tkinter as tk
|
||||||
|
from tkinter import filedialog,messagebox
|
||||||
|
from datetime import datetime
|
||||||
|
from mysql.connector import Error
|
||||||
|
|
||||||
|
def upload_excel():
|
||||||
|
# Crea una finestra di dialogo per selezionare il file
|
||||||
|
root = tk.Tk()
|
||||||
|
root.withdraw() # Nasconde la finestra principale
|
||||||
|
file_path = filedialog.askopenfilename(title="Seleziona un file Excel",
|
||||||
|
filetypes=[("Tutti i file","*.*")])
|
||||||
|
excel_filename = r"{}".format(file_path)
|
||||||
|
return excel_filename
|
||||||
2
write.py
2
write.py
@ -26,8 +26,10 @@ def write_excel(value_update):
|
|||||||
for col_index, value in enumerate(row_data):
|
for col_index, value in enumerate(row_data):
|
||||||
worksheet.write(row_index + 1, col_index, value)
|
worksheet.write(row_index + 1, col_index, value)
|
||||||
|
|
||||||
|
|
||||||
root = tk.Tk()
|
root = tk.Tk()
|
||||||
loading_label = tk.Label(root, text="")
|
loading_label = tk.Label(root, text="")
|
||||||
loading_label.pack(pady=20)
|
loading_label.pack(pady=20)
|
||||||
loading_label.config(text="Aggiornamento in corso... Attendere...")
|
loading_label.config(text="Aggiornamento in corso... Attendere...")
|
||||||
|
|
||||||
workbook.close()
|
workbook.close()
|
||||||
Reference in New Issue
Block a user