Answer the question
In order to leave comments, you need to log in
How to make a table from plain text in excel using python?
And so, there is text with camera numbers and their location. You need to make a table with two columns (see photo) For this, I chose a python. I do not know if this is the right choice, but in any case I will be glad to hear possible solutions. Here is the text itself:
north
camera1
camera2
camera3
camera4
west
camera5
camera6
camera7
camera9
Answer the question
In order to leave comments, you need to log in
def groups_to_columns(lines):
directions = ['north', 'south', 'west', 'east']
current_direction = None
for line in lines:
data = line.strip()
if data in directions:
current_direction = data
else:
yield current_direction, data
with open('data.txt') as fh:
for direction, camera in groups_to_columns(fh):
# Запись в xls
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question