简体   繁体   中英

Writing CSV data to XLS file in Python

I have a CSV file and want to Write data from CSV file to XLS file. But here is the tricky part, a new CSV file gets generated after few seconds and again I need to write the CSV data into the same Excel file that has been already generated, but now the new data will be added into new row.

This is not an homework Assignment, I have a Machine Which is generating a new csv file after few seconds. And I want my Excel sheet to be updated with the new file CSV data.

I am looking for solution or partial solution in python.

Thank you

Generally speaking, the workflow will probably be something like this using pandas:

new_data = pandas.read_csv('new_data.csv', header=0)
all_data = pandas.read_excel('file://excel_file.xlsx')
combined = all_data.append(new_data)
combined.to_excel('excel_file.xlsx')

Of course you may need to mess with some of the parameters to match up everything with your data, and possibly have this looping so it is always getting the latest changes and adding them.


Useful docs that will assist:

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM