I want to insert values from the list based on the condition,
For example, Please find below my algorithm of the code using CSV module.
out_file = open("c://Project//in.csv", "w")
header = ['List','Integer', 'Float', 'String']
l = [[4,5], 12, 2.4, "This is a string", [1,2], 45, ["Second String"]]
writer = csv.writer(out_file)
insert_header_in_the_beginning
for i in l:
if check_first_element_is_list_using_regex:
insert_in_first_column_of_first_row(i)
elif check_second_element_is_integer_using_regex:
insert_in_second_column_of_first_row(i)
elif check_third_element_is_float_using_regex:
insert_in_third_column_of_first_row(i)
elif check_last_element_is_string_using_regex:
insert_in_last_column_of_first_row(i)
new_row_starts
Desired Output
List Integer Float String
[4,5] 12 2.4 This is a String
[1,2] 45 None Second String
.....