How can I import the contents of an uploaded csv file into a drupal managed table using rules custom php?
So conceptual steps:


Extract CSV file path from the node. 
Open CSV file, read fields from header.
Read each row, convert the keys, save row using drupal_write_record().
Close the CSV.


I'm not sure how the rules integration will work I'm assuming you can pass the node into it some how. 

So for step one assuming it's stored into $node and your field is named field_csv_file we can hand the URL to fopen():

$csv_uri = $node-&gt;field_csv_file['und'][0]['uri'];


So now we can open fopen() to get a file handle:

$handle = fopen($csv_uri, 'r');


If there's no value we don't want to procede.

Read the header row:

$row = fgetcsv($handle);
$columns = array();
foreach ($row as $i =&gt; $header) {
  $columns[$i] = trim($header);
}


Then load each row and convert the format:

while ($row = fgetcsv($handle)) {
  $record = array();
  foreach ($row as $i =&gt; $field) {
    // This is pretty brittle... if someone screws up the field 
    // names the data won't be written. 
    $record[$columns[$i]] = $field;
  }
  drupal_write_record('your_table', $record);
}


Close the file:

fclose($handle);


So issues with this:


All this code it totally un-test.
What happens if someone re-uploads the file? You'll probably get duplicates.
What happens if someone messes with the headers?