In an EXCEL or XML/JSON file I have stored the contents of learning cards: one column for front side of the card, one column for the back side of the card. I want the cards to be layouted in Adobe Indesign and thought of the merge data function. Problem is: if I convert the EXCEL file into CSV in order to import it in Indesign, I lose the formatting of the text (just basic styles like bold and italic). But unfortunately Indesign is not able to merge data of an EXCEL file. Is there any other way to populate the cards from the file automatically? Maybe by a script or so? Or maybe by rewriting the existing file into another format?
So, I think I have an answer for your "second question" about how to deal with local formatting, like Bold or Italic.
The most efficient way to use styles in InDesign is to set your text using paragraph styles, and then wherever you need to change the formatting of individual characters, use a character style to make that change (i.e. instead of going to the text menu and choosing "bold" you would go to the character styles menu and choose the bold character style.) Once you have text formatted using a character style, you can later apply a paragraph style (or change the existing paragraph style), and the character formatting will remain.
I was just listening to an old episode of the InDesign Secrets podcast last night and they were were talking about the Perfect Prep Text script, which I think could solve your problem. Basically what it does is to search your text looking for local overrides (like bold and italics) and then automatically creates and applies character styles to this locally formatted text. So, you would import your text from Excel, then run the script to capture all of the local formatting as character styles and then apply the paragraph styles.
When I went to the InDesign Secrets website to find the link for Perfect Prep Text, I saw another script that seems to do the same thing, called Preserve Local Formatting, and you can find it on this page. In both cases, you will have to scroll down into the linked pages to find the hyperlink to the script itself. I believe both scripts are available to download for free (although I am a member of the website, so I couldn't test).
If you aren't familiar with scripts and how to use them, this page from InDesign Secrets will walk you through the process.
Okay, well @Vinny pointed out that I had misread the comments above, and you can't pull formatting across in a merge process (which is how I thought it worked, but thought I read something different in your question and the comments).
Another option that might work well for you is to try using nested styles. Basically the way nested styles work is that you identify a specific landmark (lots of options available: maybe a comma, an n-dash, a tab character, etc.), and then tell InDesign to apply a specific character style until it finds that landmark, and then to apply a different character style after the landmark. What's nice is that nested styles are built into a paragraph style definition, so once you get the paragraph style set up correctly, you can apply it to your imported text and the entire thing gets correctly formatted without any additional work.
This is similar to the way the GREP style that @Vinny mentioned works, but it wouldn't require that you add the formatting elements via macro. If the construction of your document doesn't allow you to define a particular landmark character, you should definitely experiment with GREP styling, because it is super powerful. Once you get either nested styles or GREP styles set up correctly, using them seems like magic!