简体   繁体   中英

Paste from clipboard to excel file

Is there a way to automate this process? 1- create new excel file 2- paste data which is ale+redy in clipboard to this new excel file with python 3- save this excel file

I have tried to find this function in openpyxl and xlsxwriter but there is only function for writing exact data to defined cells.

edit: the data in clipboard is the result from program run before this script

thanks

This method gets data copied from the clipboard and converts it into a DataFrame. You can then select whichever column you want from the DataFrame and use the to_csv method to write to the Excel file.

pandas.read_clipboard(sep='\\s+', **kwargs)
DataFrame.to_csv()

Check out the documentation :

https://pandas.pydata.org/pandas-docs/stable/generated/pandas.read_clipboard.html https://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.to_csv.html

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