Excel cell list showing as string in Python

Question:

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?

Asked By: OliAK

||

Answers:

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.

Categories: questions Tags: , , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.