Hey, thanks a lot for the support!
I know openpyxl, have been working with it before, it’s just that I have never worked with data in this format, i.e. all information in rows and only one single column… My idea was to extract those specific rows, interview_number, speaker, date, and then create new columns so that they are all split up. However, I haven’t even been successful at extracting those rows. What I’d ideally do is establish that all the rows follow the same format, interview number, speaker, date text, and then loop over interview numbers 1 to 400 to repeat the process. I have been unsuccessfully trying something along those lines:
If I looped trough the rows how could I tell Python which ones to extract?
I know openpyxl, have been working with it before, it’s just that I have never worked with data in this format, i.e. all information in rows and only one single column… My idea was to extract those specific rows, interview_number, speaker, date, and then create new columns so that they are all split up. However, I haven’t even been successful at extracting those rows. What I’d ideally do is establish that all the rows follow the same format, interview number, speaker, date text, and then loop over interview numbers 1 to 400 to repeat the process. I have been unsuccessfully trying something along those lines:
for row in rows: sheet.append(row) for row in sheet.iter_rows(min_row=1, min_col=1, max_row=6, max_col=3): for cell in row: print(cell.value, end=" ") print() book.save('iterbyrows.xlsx')However, I don’t know how to tell Python which rows “are special” to me, i.e. the first 3 rows after an empty row, interview number, speaker, date. Shall I loop over the interview number? Or use the fact that between interviews there is an empty row?
If I looped trough the rows how could I tell Python which ones to extract?
file = "enter_path_to_file_here" wb = openpyxl.load_workbook(file, read_only=True) ws = wb.active for row in ws.iter_rows("E"): for cell in row: if cell.value == "interview": print(ws.cell(row=cell.row, column=2).value)I’m honestly at my wits’ end.