-1

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

Charlie Clark
  • 18,477
  • 4
  • 49
  • 55
Luka Herc
  • 11
  • 1
  • 4
  • can you give example of the data? – Ron Serruya Jan 07 '20 at 11:26
  • 1
    1. writing to excel file using python: https://stackoverflow.com/questions/13437727/writing-to-an-excel-spreadsheet 2. pasting from clipboard using python: https://stackoverflow.com/questions/46817290/how-do-i-paste-the-copied-text-from-keyboard-in-python – xyz Jan 07 '20 at 11:32
  • the data is combination of numerical data, empty spaces and letters. here is a link to google drive https://drive.google.com/open?id=184rE4FjB8JjHEMSs-E63tek-8GbuL8sb – Luka Herc Jan 07 '20 at 11:33

1 Answers1

1

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

Sami Belkacem
  • 336
  • 3
  • 12
  • The OP wants probably a `XLSX` file, add `.to_excel(...` to your reference list. – stovfl Jan 07 '20 at 11:36
  • thanks, but I still get the Traceback error Traceback (most recent call last): File "C:/Users/Luka/PycharmProjects/untitled2/novo.py", line 36, in pandas.read_clipboard(sep='\\s+', **kwargs) TypeError: read_clipboard() argument after ** must be a mapping, not module – Luka Herc Jan 07 '20 at 13:36