df = pd.read_csv(
'ventas_norte.csv',
sep=';',
encoding='utf-8',
)
!pip install openpyxl
df_xlsx = pd.read_excel(
'ventas_sur.xlsx',
sheet_name=None
)
df_xlsx = pd.concat(df_xlsx.values(), ignore_index=True)
df_xlsx.head()
import json
with open('ventas_este.json') as f:
data = json.load(f)
df_json = pd.json_normalize(data)
df_csv = df_csv.rename(columns={
"ID_Transaccion": "id",
"Fecha_Venta": "fecha",
"Nom_Producto": "producto",
"Cantidad_Vendida": "cantidad",
"Precio_Unit": "precio_unitario"
})
df_csv["region"] = "Norte"
df_xlsx = df_xlsx.rename(columns={
"SalesID": "id",
"Date": "fecha",
"Item": "producto",
"Qty": "cantidad",
"UnitPrice": "precio_unitario"
})
df_xlsx["region"] = "Sur"
df_json = df_json.rename(columns={
"id_orden": "id",
"timestamp": "fecha",
"detalles_producto.nombre": "producto",
"detalles_producto.specs.cantidad": "cantidad",
"detalles_producto.specs.precio": "precio_unitario"
})
df_json["region"] = "Este"
df_total = pd.concat(
[df_csv, df_xlsx, df_json],
ignore_index=True
)
df_total.to_csv("ventas_consolidadas.csv", sep=",", encoding="utf-", index=False)