Confluence Plugin: How to create space and pages programmatically from imported CSV?

I want to add a button to the system.header/left, which I already did. And when I click that button, I want a file picker popup to choose my CSV.

From the CSV content, I want to create space and pages.

I’ve browsed through the documents and tutorials, but I can’t find anything alike.

Could you point a direction or steps for me? At least, point me to something relevant?.