I use datatool to get data and row spacing can change.
Count word/character of Total character of (Text A + Text B) if:
Total charater of (Text A + Text B) < 20 characters => set row space of text in tcolorbox = 1.5 cm
Total character of (Text A + Text B) = 21 - 50 characters => set row space of text in tcolorbox = 0.8 cm
Total character of (Text A + Text B) > 50 charaters => set row space of text in tcolorbox = 0.3 cm
Minimal working code:
\documentclass{article}
\usepackage[many]{tcolorbox}
\usepackage{wrapfig}
\usepackage{lipsum}
\tcbset{colframe=blue!75!black,colback=white}
\usepackage{filecontents}
\begin{filecontents*}{file.tex}
No,TextA,TextB
1,a a a a a a a a a a a a a a a a a a a a,b b b b b b
2,a a a a a a a a a a,b b b b b b
3,a a a a a a a a a a,b b b b b b b b b b b b
4,a a a a a a a a a a,b b b b b b b b b b b b b b b b b b
5,a a a a a a a a a a a a a a a,b b b b b b
6,a a a a a a a a a a a a a a a a a a a a,b b b b b b
7,a a a a a a a a a a a a a a a,b b b b b b b b b b b b
\end{filecontents*}
\usepackage{datatool}
\DTLloaddb[autokeys=false]{file}{file.tex}
\begin{document}
\DTLforeach*
{file}% Database
{\No=No,\TextA=TextA,\TextB=TextB}{%
%\begin{mybox}[height=4.5cm]
\begin{tcolorbox}[height=4cm,width=6cm]
\begin{wrapfigure}{R}{1.5cm}
\centering
\includegraphics[width=2cm,height=2cm]{example-image-a}
\end{wrapfigure}
\No \quad \TextA \quad \TextB\par
\end{tcolorbox}
\newpage
}%
\end{document}
Many thank

tcolorboxoffersfittinglibrary to do the inverse task, you can reduce fontsize to fit certain text inside a defined box. May be you could consider it as an alternative solution. – Ignasi Apr 08 '19 at 08:03