Here is an approach using the readarray
and listofitems
packages. I'm not sure if the format of your input file is rigid or not. The code could be streamlined significantly if the input file were in a simpler format. Nonetheless, using the OP's specified format, the result can be achieved. Note that this approach allows verse ranges to be specified across chapter boundaries.
\documentclass{article}
%\usepackage{fontspec}
\usepackage{readarray,listofitems}
\ignoreemptyitems
\begin{filecontents}{bible.csv}
chapter,verse,text
1,1,{test chapter 1, verse 1}
2,1,{test chapter 2, verse 1}
2,2,{test chapter 2, verse 2}
2,3,{test chapter 2, verse 3}
3,1,{test chapter 3, verse 1}
3,2,{test chapter 3, verse 2}
\end{filecontents}
\def\chapvrses[#1,#2]-[#3,#4]{%
\ifnum#1=#3
\inchapvrses{#1}{#2}{#4}%
\else
\foreachitem\zz\in\chapvrs[]{%
\ifnum\zzcnt<#1\else
\ifnum\zzcnt>#3\else
\ifnum\zzcnt=#1
\inchapvrses{#1}{#2}{\listlen\chapvrs[#1]}\
\else
\ifnum\zzcnt=#3
\inchapvrses{#3}{1}{#4}%
\else
\inchapvrses{\zzcnt}{1}{\listlen\chapvrs[\zzcnt]}\
\fi
\fi
\fi
\fi
}%
\fi
}
\newcommand\inchapvrses[3]{%
\foreachitem\z\in\chapvrs[#1]{%
\ifnum\zcnt<#2\else
\ifnum\zcnt>#3\else
\ifnum\zcnt=#2\else\ \fi
\z
\fi
\fi
}%
}
\begin{document}
% Read file into macro
\readarraysepchar{;}
\readdef{bible.csv}\Bible
% Convert format into something easier: verse, verse; new-chapter-verse, verse, etc.
\newtoks\zzz
\newcommand\addtozzz[1]{\global\zzz\expandafter{\the\zzz#1}}
\newcommand\xaddtozzz[1]{\expandafter\addtozzz\expandafter{#1}}
\newcommand\xxaddtozzz[1]{\expandafter\xaddtozzz\expandafter{#1}}
\newcounter{Bibchap}
\setsepchar{;/,}
\readlist\chapvrs{\Bible}
\foreachitem\z\in\chapvrs[]{%
\ifnum\zcnt=1\else
\ifnum\theBibchap=0 \stepcounter{Bibchap}\else
\ifnum\chapvrs[\zcnt,1]=\theBibchap\relax
\addtozzz{,}%
\else
\stepcounter{Bibchap}%
\addtozzz{;}%
\fi
\fi
\xxaddtozzz{\chapvrs[\zcnt,3]}%
\fi
}
\expandafter\def\expandafter\Bible\expandafter{\the\zzz}
% Read \Bible (in preferred format) as a list
\readlist\chapvrs{\Bible}
\begin{quote}
\chapvrs[2,3]
\end{quote}
\begin{quote}
\chapvrses[2,2]-[3,1]
\end{quote}
\end{document}
If one instead chose a simpler file format, with no indexing numbers in the file, just comma verse separators and semicolon chapter separators:
{verse},
{verse};
{new-chapter-verse},
{verse},
etc.
the code would simplify as
\documentclass{article}
%\usepackage{fontspec}
\usepackage{readarray,listofitems}
\ignoreemptyitems
\begin{filecontents}{bible.csv}
{test chapter 1, verse 1};
{test chapter 2, verse 1},
{test chapter 2, verse 2},
{test chapter 2, verse 3};
{test chapter 3, verse 1},
{test chapter 3, verse 2};
\end{filecontents}
\def\chapvrses[#1,#2]-[#3,#4]{%
\ifnum#1=#3
\inchapvrses{#1}{#2}{#4}%
\else
\foreachitem\zz\in\chapvrs[]{%
\ifnum\zzcnt<#1\else
\ifnum\zzcnt>#3\else
\ifnum\zzcnt=#1
\inchapvrses{#1}{#2}{\listlen\chapvrs[#1]}\
\else
\ifnum\zzcnt=#3
\inchapvrses{#3}{1}{#4}%
\else
\inchapvrses{\zzcnt}{1}{\listlen\chapvrs[\zzcnt]}\
\fi
\fi
\fi
\fi
}%
\fi
}
\newcommand\inchapvrses[3]{%
\foreachitem\z\in\chapvrs[#1]{%
\ifnum\zcnt<#2\else
\ifnum\zcnt>#3\else
\ifnum\zcnt=#2\else\ \fi
\z
\fi
\fi
}%
}
\begin{document}
\readarraysepchar{}
\readdef{bible.csv}\Bible
\setsepchar{;/,}
\readlist\chapvrs{\Bible}
\begin{quote}
\chapvrs[2,3]
\end{quote}
\begin{quote}
\chapvrses[2,2]-[3,1]
\end{quote}
\end{document}