Hello Praveen,
You could use the php function fopen() to open the CSV file, then you could process the CSV line by line by calling fgetcsv() which will give you an array for each record. Then when at the end of the file you should close the file with fclose().
As for creating users, you could use the Moodle functions for that. I don't know how embellished you want to get with your validation routines so I will outline a few things I think might be useful for you.
In my case I have to verify if the user exists or not and we use email address as the primary key basically so I retrieve the user from Moodle's database using the global $DB object:
$user = $DB->get_record('user', array('email'=>$values["Email"]));
Then if the user does not exist, I need to create it, so I just make a new object and fill the values in, like so..
$user = new object();
$user->password = "whatever password you want";
$user->idnumber = $values["StudentID"];
$user->firstname = $values["FirstName"];
$user->lastname = $values["LastName"];
$user->username = $values["Username"];
$user->phone1 = $values["HomePhone"];
$user->phone2 = $values["MobilePhone"];
$user->email = $values["Email"];
Then I make a call to create that user:
$new_userid = user_create_user($user, false, false);
Then I want to make sure they change their password after first login:
set_user_preference('auth_forcepasswordchange', 1, $new_user);
In order to access the manual enrollment methods you need to make a call to retrieve or get the enrollment plugin. This is how I do it:
$plugin = enrol_get_plugin('manual');
Then I want to enroll the user into their proper course, so I use the enrollment plugin to call the enrol_user() method:
$plugin->enrol_user($course_instance, $user->id, $role->id);
$course_instance is gotten in this kind of fashion. I am leaving out the checking whether $course = true in this example because it is code that is mixed in with some other proprietary stuff which I don't want to reveal, but you want to make sure that $course is not null. We use the course's Id Number:
$course = $DB->get_record('course', array('idnumber'=>$values["CourseIdNumber"]));
$course_instance = $DB->get_record('enrol', array('courseid'=>$course->id, 'enrol'=>'manual'), '*', MUST_EXIST);