Hello, hope I can help. You’re in luck, I enjoy python and happen to be learning a bit of it right now. However, i bet you could do all of it with KNIME.
I’m visual, need to break apart your sentence to help solve.
1. I want to copy a Sheet…
With two nodes, I’m doing 1,2,3. Notice I write a new file, leaving the previous sheet to stay VS deleting it.
2. in value without formulas…
Screenshot above shows knime native does not take the =C8*2 formula. and copies only values.
3. and remove an another sheet.
Most tools like KNIME query source systems, files, and LOAD that information to a target destination. Deleting content is not typical.
Have you considered calling the new source output the previous file and potentially forget about doing the remove? Maybe another way of thinking about it. Not sure the complete use case.
You will be surprised how easy python is when you don’t find the wrong blog post.
For example, I write about web scraping with python and before learning this, I ran into a few bad blogs…
So below, I’m linking you to w3school, where they have good code, good examples, and enough examples/code you need to do what you’ve requested.
Knime can package the python code OR be used to kick off the code. (im still learning, im sure there’s more)
Knime can help you build the data for your python service, it is great at building lists or arrays [ x ]
The python code you need:
#import the openpyxl library, google “how to pip install openpyxl”
import openpyxl
workbook=openpyxl.load_workbook(‘testdel.xlsx’)
workbook.get_sheet_names()
[‘Sheet1’, ‘Sheet2’, ‘Sheet3’]
std=workbook.get_sheet_by_name(‘Sheet2’)
workbook.remove_sheet(std)
workbook.get_sheet_names()
[‘Sheet1’, ‘Sheet3’]
workbook.save(‘testdel.xlsx’)
#byebye sheet2, byebye
I recommend you build a function with this, to make it easier for you, & once completed, you can turn it into a module and give it away here.
Functions are rather helpful. Here’s a demo of how you can build a function with the above code, to limit the amount of handholding you or your code will need. I like writing these because it makes my code easier to read or easier to teach/support.
Here’s an example of how I’m using variables + math.
def a(x,y):
___ return 1 + x + y
print ( “using return” )
print (a(0,0))
print (a(1,1))
print (a(2,2))
print (a(3,3))
def b(m):
___ print (1 + m)
print ( “using print” )
b(0)
b(1)
b(2)
b(3)
Goodluck mate.