Python Lesson: Using Pandas to upload Excel files to MySQL

preview_player
Показать описание
import pandas as pd
import os

path = 'D:\YourFolderPath'

host = " ",
user = " ",
passwd = " ",
database = " "
)

sql = "insert into batcherrorlogs (`FullID`, `Error Message`, `Filename`) VALUES (%s, %s, %s)"
sql2 = "update batcherrorlogs set ID = replace(`FullID`,'P_','')"
sql3 = "update batcherrorlogs set Dayfor = replace(replace(Filename,'ErrorLogs_',''),'.xlsx','')"
sql4 = "update batcherrorlogs set `Date` = date(`Dayfor`)"
sql5 = "truncate batcherrorlogs"
for file in listoffiles:
if ".xlsx" in file:
filepath = 'D:\YourFolderPath\\' + file
for i in range(len(df)):

#python #pandas #excel #automation #upload #etl #datascience #data #science #bi #businessintelligence #business #intelligence
Рекомендации по теме