create a drop down list for a entire column in excel using openpy python - openpyxl

I would like to create a dropdown list in excel sheet for entire column that matches with number of lines in the input file using OpenPy . I can able to create it for one cell in a column but not for entire column.
here is the link for similar ques:
OpenPyXL: Is it possible to create a dropdown menu in an excel sheet?
my code:
with open('input.csv') as f:
reader = csv.reader(f, delimiter=',')
for row in reader:
ws.append(row)
data_val = DataValidation(type="list",formula1='waiver1,waiver2,waiver3')
ws.add_data_validation(data_val)
data_val.add(ws['H1'])
Instead of adding drop down list to only "H1" column,I want to add dropdown list for "H" column up to where the data (here input.csv) is present. How can i do that?
Please help me.

Related

Is there a way to update a pandas table with to_html() keeping the links intact?

Newbie to pandas here.
I am reading a html table to pandas data frame using read_html. This table contains a column (column 3) with clickable url .
I want to append this table with new row . But after appending and using table.to_html command, only the last row clickable url is there. All previous clickable url become unclickable
table = pd.read_html(page_content)
table = table[0]
I want to append a row to this table with clickable url hyperlink and then write out html.
table.loc[len(table.index)] = [sys.argv[1], report ,make_clickable(jiraurl,iss) , sys.argv[3]]
newHTML = table.to_html(index=False,render_links=True,escape=False)
But this only makes the newly added link clickable and all previous link in the table just become unclickable with table.to_html
Am i missing something?
make_clickable function is as follows
def make_clickable(url, name):
return '{}'.format(url,name)
I hope i made my issue clear.

Pandas Dataframe unable to reference column name in Plotly Dash Dropdown when set to reference in google sheets column

I am currently busy with a Plotly Dash Web Application and busy creating a dropdown referencing a column from a pandas dataframe I am reading in from a CSV file.
The issue is it is not able to read the column and I have seen it is because the column is actually a reference of another sheet I.e =RawData!A1.
I have managed to print the column so I know it exists in the dataframe and all the data is printing correctly however, Plotly Dash does not want to populate the dropdown with the label and values - my current line of code is:
options=[{'label': i, 'value': i} for i in df.CategoryName.unique()],
Category name in Google Sheets is referring to =RawData!A1
What I have tested:
Ammended my sheet name to read directly from my RawData sheet and it works fine - This is not a solution that I want though, this lead me to see the issue was with the reading from the referenced column.
Attempted using column index instead:
options=[{'label': i, 'value': i} for i in df.iloc[:,1].unique()],
Again this worked for printing but not to populate the dropdown in plotly dash.
Any advise will be greatly appreciated!
So by actually adding some data cleaning to remove rows at the bottom of my dataset in pandas it fixed my issue.
I added a remove nan based on my column CategoryName and by doing that my dropdown worked
df = df[df['CategoryName'].notna()]
The reason it worked makes sense - I setup my copy form to =RawData!A:A so my RawData at the moment only comprising of 123 rows, by row 125 in my reference sheet it was referencing a blank column causing the dropdown to have an error showing a reference to something that does not exist, very funny error but logical at the same time. Not sure if this will help many people but hopefully it will assist somebody!

Export values to specific cell in an excel file (using PDI)

I have in table input result as below:
I would like pass this result to excel file in specific row.
For example number_record I want to write to column J5, amount_ma to column K2 and so on. Can something like this be done in pentaho?
I have prepare a solution for you HERE. Using this solution, you can specifically tell which field you want to insert in which position in Excel. Like in my solution i told to insert field [NUMBER_RECORD to C5, AMOUNT_MA to D7,AMOUNT_WD to B5] Please run transformation "getData.ktr".
Add a new sheet to this Excel file, and output a line with the result to the new sheet. And on the old sheet in the cells you need, add formulas with a link to the first row in the new sheet

excel vba - transferring multiline cell content to multiple rows

In Excel, my requirement is to transfer multiline cell content to multiple rows. I have attached some sample input data and output data. Please let me know on how to proceed. Thanks in advance.
Select column "name" then use Ctrl+G->bank->type "=" then hit down arrow and Ctrl +Enter-> all blank cells will be filled as shown as ur output data ( unmerge first if column "name" contains merged cells )

Is it possible to Populate a listbox with a non-contiguous named range?

I have a single column list box, which I want populated by table names that are on one worksheet. I've Ctrl clicked all the names and named them, however when I enter the range name into the properties table of the userform, they don't show up. What am I doing wrongly?
I would also state that I want to avoid creating a separate list on another worksheet.
What is intriguing is the fact that when you copy non contiguous data and paste it, it pastes contiguously. How does excel do this? I've recorded the macro and it's just 'activesheet.paste'. Can you paste into an array? ...to then use the array as the list, without having to create another list?
you can do this:
arrayname = rangename.value 'set named range to array
sheet1.listbox1.list = arrayname 'set array to listbox values