I'm trying to copy multiple cells from a table of a document and I want to be able to press a hotkey that will act as a paste function, pasting one cell at a time starting with the first.
| data |
|---|
| Cell 1 |
| Cell 2 |
| Cell 3 |
Hotkey paste Cell 1, Hotkey paste Cell 2, Hotkey paste Cell 3
import pandas as pd
import keyboard
import pyperclip
df = []
var = 0
def load_cells():
print("Load Hotkey pressed")
global df, var
df = pd.read_clipboard(sep=",", names=["vals"])
var = len(df)
return df
def paste_cell():
print("paste Hotkey pressed")
global df, var
if var < len(df):
pyperclip.copy(str(df.iloc[var, 0]))
var += 1
keyboard.add_hotkey('ctrl+alt+x', load_cells)
keyboard.add_hotkey('ctrl+alt+z', paste_cell)
keyboard.add_hotkey('ctrl+alt+a', print(df))
My current error is "TypeError: 'NoneType' object is not callable" but I've be struggling with many versions of this and think I think I'm not headed in the right direction.
Print functions added to attempt to locate errors but I haven't been able to get anything loaded to the dataframe.
Help appreciated.
I can't comment yet because I don't have fifty rep. But are you saying that when you press a hotkey you get a TypeError? If so that means the function you are trying to call is
not defined, what about when you press the hotkey that callsprint(df)? I'll edit my answer once I get some more information.