@SuppressWarnings({"squid:S2093"}) // ignore try-with-resources
  public static int importFromTargetPath(
      String host, int port, String username, String password, String targetPath, String timeZone)
      throws IoTDBConnectionException {
    try {
      session = new Session(host, port, username, password, false);
      session.open(false);
      timeZoneID = timeZone;
      setTimeZone();

      File file = new File(targetPath);
      if (file.isFile()) {
        if (file.getName().endsWith(Constants.SQL_SUFFIXS)) {
          importFromSqlFile(session, file);
        } else {
          importFromSingleFile(session, file);
        }
      } else if (file.isDirectory()) {
        File[] files = file.listFiles();
        if (files == null) {
          return Constants.CODE_OK;
        }

        for (File subFile : files) {
          if (subFile.isFile()) {
            if (subFile.getName().endsWith(Constants.SQL_SUFFIXS)) {
              importFromSqlFile(session, subFile);
            } else {
              importFromSingleFile(session, subFile);
            }
          }
        }
      } else {
        ioTPrinter.println("File not found!");
        return Constants.CODE_ERROR;
      }
    } catch (IoTDBConnectionException | StatementExecutionException e) {
      ioTPrinter.println("Encounter an error when connecting to server, because " + e.getMessage());
      return Constants.CODE_ERROR;
    } finally {
      if (session != null) {
        session.close();
      }
    }
    return Constants.CODE_OK;
  }
Specifying a CSV file or a directory including CSV files that you want to import. This method
can be offered to console cli to implement importing CSV file by command. Available for Cli
import

@param host
@param port
@param username
@param password
@param targetPath a CSV file or a directory including CSV files
@param timeZone
@return the status code
@throws IoTDBConnectionException
iotdb-client/cli/src/main/java/org/apache/iotdb/tool/data/ImportData.java