Home > Software design >  Excel cell list showing as string in Python
Excel cell list showing as string in Python

Time:07-30

I have a excel table, in which I have a column as below. Which is label list from JIRA

enter image description here

I would like to take each cell value as a list by running a for loop. For example:

List=['[Engineering]','[Non-Engineering]']

Then I will use it to update my JIRA issue label by following

issue.update(fields={'labels': List})

However loop in python take this as string only as below.

enter image description here

How can I have this cell value as a list?

CodePudding user response:

Just remove the unneeded character from the string, and then split it by the delimiter.

Example:

label = "['[Engineering]','[Non-Engineering]']"


label = label[1:]
label = label[:-1]
label = label.replace("'","")

label_list = label.split(',')

Output

>>> label_list
['[Engineering]', '[Non-Engineering]']

Do this in the for loop and save the lists in the dictionary.

  • Related