0

I have a list of lists like the following one:

[[5, 6], [10, 11], [14, 15]]

I want to output them as a csv file maybe using pandas to_csv in the following format:

Start End
5     6
10    11
14    15

How can I do this? I have an idea of flattening the list and then making every two elements as a comma-separated line of a CSV file. But I think it can be done more easily.

Md Abrar Jahin
  • 374
  • 3
  • 9

1 Answers1

1

If you want to use pandas you can use:

data = pd.DataFrame(data_list, columns=["start","end"])
data.to_csv("myfile.csv")
Bendik Knapstad
  • 1,409
  • 1
  • 9
  • 18