I have python script that reads a .txt. file and appends items to a two different lists:
//Edit: fragment of my input file:

list_data_type = [
['void'], ['uint8'],
[['uint8'], ['uint32']], ['void'],
['void'], ['void'], ['void']
]
list_arg_parameter = [
[None], ['f_MbistTestType_u8'],
['f_MbistTestType_u8', 'f_chip_id_u32'], [None],
[None], [None], [None]
]
I want to join corresponding items of both list, which I know can be done with zip function, but I want to print the result of both lists in a .csv file, and I want that those two list with 2 elements would be written into same slot and it would look like this:
file_name_1;function_name_1; void (None)
file_name_1;function_name_2; uint8 f_MbistTestType_u8
file_name_1;function_name_3; uint8 f_MbistTestType_u8, uint32 f_chip_id_u32
Also I don't want any "[]" or "''" signs. Right now I tried to convert both lists to a string, strip all unnecessary brackets, convert those strings back to list via this function:
def Convert(string):
li = list(string.split(" "))
return li
And then use simple for loop to make pair of elements:
for elements in zip(list_data_type_strpd, list_arg_parameter_strpd):
list_func_arg_combined.append(' '.join(elements))
But the result looks like this:
'void '
'uint8 f_MbistTestType_u8'
'uint8 f_MbistTestType_u8'
'uint32 f_chip_id_32'
'void '
'void '
'void '
'void '
And I would like it, like this:
'void '
'uint8 f_MbistTestType_u8'
'uint8 f_MbistTestType_u8, uint32 f_chip_id_32'
'void '
'void '
'void '
'void '
Maybe I turn those list to string unnecessarily? Maybe there is a easier way to accomplish my goal? Any help, critique or different solutions are welcome.