Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
525 views
in Technique[技术] by (71.8m points)

excel file wont transfer to sqlite via python

I am using python to download and save an xlsx file from the web using a url. Next, I am using python code to convert to sqlite (.db). The problem is that the xlsx file is not being converted into a db file. But when I manually open the xlsx file and hit the save button then use python to convert that xlsx file to a db file it works. It seems like the file is not being downloaded correctly??

Thank you for the help!

    def download_and_save_data(url, filename_response):
        retrieve(url, filename_response+'.xlsx')

    def convert_xlsx2db(filename_response):
        con=sqlite3.connect(filename_response+".db")
        wb=pd.read_excel(filename_response+'.xlsx', sheet_name='Data', engine='openpyxl')
        wb.to_sql(filename_response, con=con, if_exists="replace")
        con.close()

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...