Batch API is setup in my module but it does not open batch window progress I am learning hot to use Drupal for my physics PHD. I was studying how to insert a batch into my custom module.
I wrote a simple module which allows to upload a CSV through a form, check the extension and save it into a directory. This is just a try because i want to use batch API for another custom module
Here is the code:

/**
* Implementation of hook_menu()   
*/

function rhmtts_csvimport_menu() {
     $items['rhmtts/csvimport'] = array(
           'title' =&gt; 'Import CSV files',
           'page callback' =&gt; 'rhmtts_csvimport_page_default',
           'type' =&gt; MENU_NORMAL_ITEM,
           'access callback' =&gt; TRUE,
           );

     return $items;
}


function rhmtts_csvimport_uploadform() {
      $form['#attributes'] = array('enctype' =&gt; "multipart/form-data");
      $form['csvfile'] = array(
           '#type' =&gt; 'file',
           '#title' =&gt; t("Upload a CSV file"),
           '#size' =&gt; 40,
           );
      $form['submit'] = array(
           '#type' =&gt; 'submit',
           '#value' =&gt; t('Submit'),
           );
  return $form;
 }

           /////// Setup a batch //////////////

  function rhmtts_batch_submit(){

      $batch=array(
          'title' =&gt; t('Importing CSV ...'),
          'operations' =&gt; array(),
          'init_message' =&gt; t('Commencing'),
          'progress_message' =&gt; t('Processed @current out of @total.'),
          'error_message' =&gt; t('An error occurred during processing'),
          'finished' =&gt; 'rhmtts_csvimport_finished',
          );


      batch_set($batch);
      $batch['operations'][] = array('rhmtts_csvimport_uploadform_submit',                    array());

      }

     ////// Define finished function ////////////////////////////

   function rhmtts_csvimport_finished($success, $results, $operations) {

     if ($success) {
        $message = t('All users have had first and last names processed.');
      }
     else {
     $message = t('Finished with error.');
     }
   drupal_set_message($message);
   }

   ///// Methods definition ////

   function rhmtts_csvimport_uploadform_submit($form, &amp;$form_state) {



   // create a csv upload directory in sites/default/files if it doesn't exist 
   // yet
   $filepath = 'public://csvuploads';
   file_prepare_directory($filepath, FILE_CREATE_DIRECTORY);

   // save the uploaded file
   $file = file_save_upload('csvfile', array('file_validate_extensions' =&gt;             array('CSV')), $filepath, FILE_EXISTS_REPLACE);
   drupal_set_message('The file you have uploaded is: &lt;pre&gt;'.print_r($file,    TRUE).'&lt;/pre&gt;');

  // now read from it
  $realpath = drupal_realpath($file-&gt;uri);
  drupal_set_message("The real path of the file is $realpath");
  $fh = fopen($realpath, 'r');

  $table_header = NULL;
  $table = array();
  while(($row = fgetcsv($fh, NULL,';')) !== FALSE){
  if($table_header == NULL) {
  foreach($row as $field) {
    $table_header[] = $field;
    };
    continue;
    };
    $table_row = array();
    for($i = 0; $i &lt; count($table_header) ; $i++) {
    $table_row[$table_header[$i]] = $row[$i];
    };
    $table[] = $table_row;
    }
    fclose($fh);
    drupal_set_message("You have uploaded: &lt;pre&gt;".print_r($table, TRUE)."&lt;/pre&gt;");
   }


When i choose a file from the form it completed the operation, but the usual page showing batch progression is not showed. Is this because the operation is to fast? Or there are other problems in the code?

Many thanks

Alberto
your menu callback function is rhmtts_csvimport_page_default. This does not exist or currently does nothing.
Your form function rhmtts_csvimport_uploadform has this submit handler rhmtts_csvimport_uploadform_submit and it never calls or creates your batch function called rhmtts_batch_submit.


Your code is more or less all there I would:


use drupal_get_form as my hook_menu callback function and give it the name of my form function.
I would add my batch function onto the form submit handlers for my form as outlined here https://www.drupal.org/node/180528. Then it should all work.