Copy simple text from both values and comments (.ods file) an maintain pairing?

UPDATED, SIMPFLIED:
in the .ods attachment, there are some questions (values of cells) and answers (comments of cells). Is it possible to automatically transform it all into some simple text, f.e.

Question 1 - Answer 1
Question 2 - Answer 2

?
The order of items is not important.

Sample.ods (10.2 KB)

ORIGINAL QUESTION:

I have an .ods file containing both questions and answers, where questions are inputted as cell values while answers are provided as comments.

I can generate an .odt document containing a basic table of many rows and two columns to input the data I wish to recall. Nevertheless, utilizing an .ods file allows me to create a structure resembling a “mind map” with questions, showcasing the logical information in an organized manner (and it is clearly ordered as it would be the case in an .odt file with comments).

It would be helpful to be able to automatically copy the text of questions and matching answers so that I would obtain something like simple text split into two parts, questions and answers. So I could use it for example for Anki (a spaced repetition app).

Could it be simply done? If so, how?

(Supplementary question:

*Certain cells are highlighted with a particular color background, indicating to me that these questions require extra attention outside of the regular review schedule. *

It would be helpful to be able to automatically find all cells with a certain background color — either on one .ods sheet, the entire file, or all cells with some simply text “code” at the beginning, f. e. the same date — and then copy the text of questions and matching answers only “from here”. Is it possible?

I´m not expecting that it would be easy and that I would manage it as my computer skills are limited, and I suspect that some new script would be needed — but perhaps there is a simple solution? Do you believe a programmer can handle this task and if yes, how much would it cost — approximately - I don´t know how difficult this task would be and if I could afford to pay for it?)

Thank you.

Its not really clear to me, do you need to extract pairs of cell-content and annotation-text to some text-file|csv-file or is it exactly the opposite way… from some other to …ods?

  1. One question per “question” (thread) please.
  2. I am afraid I cannot understand exactly what you are trying to achieve.
  3. Please attach a reduced example .ods showing what you have and what you want to get. There is this related post.

From .ods to text.

I would like to extract text from the attached file, f. e. in this form:

Question 1 - Answer 1
Question 2 - Answer 2
Question 3 - Answer 3.

It´s not important to me:

  • what exactly is between questions and answers,
  • the order of questions.

Sample.ods (10.2 KB)

def extract_Q_A_pairs_to_txt(*_):
    doc = XSCRIPTCONTEXT.getDocument()
    sheet = doc.Sheets["List1"]
    with open("Q_and_A.txt", "w", encoding="utf8") as q_and_a:
        for annotation in sheet.Annotations:
            q = annotation.AnnotationShape.Anchor.String
            a = annotation.String
            q_and_a.write(f'"{q}"\t"{a}"\n')

The code is simple enough, but maybe you need help to manage and organize this python-stuff with apso.oxt from here

Hi, I tried it, I typed it and it reports an error.
Can you advise me?

the advice was already in my last comment:

This is a question which may end up in an endless sequence of additional “tiny questions in addition”.
What you try to achieve will not be possible without resorting to user code.
If at all, you should use such a design only if you are sufficiently familiar with one of the script languages and with the way it can be used for LibreOffice documents.
The “lingua franca” for small user routines mainly needing the API, is LibO Basic, but it doesn’t make any sense to paste Python code into the body of a Basic Sub…
(When opening files containing code, always permit the execution only after having checked the code for the absence of possibly malicious parts.)
See attachment:
disask113383_strangePairing.ods (22.9 KB)