List of dictionary in CSV file

Hi,

I use DataDriver to set a CSV file with different types of parameter and it works fine.
My need is to set a list of dictionary in one parameter in order to iterate it in a Keyword.

CSV file :
e{attributes}
[{“name”=“John”,“age”=“33”},{“name”=“Alice”,“age”=“40”}]

Error message :
[ ERROR ] Calling method ‘_start_suite’ of listener ‘DataDriver’ failed: SyntaxError: invalid syntax (, line 1)
Variable ‘${attributes}’ not found.

If the CSV file has got a list with non dictionary value, the test execution is OK.

Do you have any clue to set a list of dictionary in CSV file ?

Thanks a lot for your ideas.

That is not correct python syntax.

Dictionaries are created like that:

my_dictionary = {"name":"John", "age":"33"}

So your List shall be like this:

[{"name": "John", "age": "33"}, {"name": "Alice", "age": "40"}]

and you should also take care of that “double”-Quotes.
Sometimes in Excel you do not get "but you get or . That is something different…

1 Like

My bad, I feel guilty for = and : :slightly_frowning_face:

For double quote, the CSV file is edited with Vi.

Thank you René for your outside look.