Importing files within a transaction?

Is it possible to import data from a file within a transaction? Looking at pystardog for example, the import_file method is on the Admin connection, which doesn't have transactional methods like the Connection class does.

One possible use case here would be to do some validation on imported data (possibly via SHACL, possibly via other mechanisms) and roll back if there is an issue.