I want to write a CSV file with a specific format, so I can train with the data. I need every information per input in one line. The charList is a list of chars (with length 108) in ascii numbers.
Instead of put the list in the csv, I want to have every char seperately. So one CSV line should look like:
0.2344,0.234565,0.245534,45,27,34...34
You didn't show example input data and what result you get at this moment so I will use my data.
You have to flatten
it. You can use +
to join lists
If you have
data = [12, 34, ["A", "B"], 56]
where data[2]
is ["A", "B"]
then
result = data[:2] + data[2] + data[3:]
gives
[12, 34, "A", "B", 56]
If you have
data = [12, 34, "AB", 56]
then you can use list
to convert string into list
result = data[:2] + list(data[2]) + data[3:]
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.