Programmatically created nodes don't appear unless opened and saved I've written a simple script that iterates over a CSV file and creates nodes in Drupal. All of the nodes are present in the admin interface but do not appear on the site unless I manually click 'Edit' then immediately save. This is a real problem because I do not have time to open each and every node. Funny thing is, this doesnt happen for every node.

A simplified version of my code

 while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {              
    $title = $data[1];
    $address1 = $data[2];
    $address2 = $data[3];

    // Add a node
    $node = new stdClass();
    $node-&gt;type = 'store_location';
    node_object_prepare($node);
    $node-&gt;status = 1; # published or not...
    $node-&gt;promote = 0;
    $node-&gt;uid = 1; // ID of author
    $node-&gt;created = date('U', strtotime('now'));

    $node-&gt;language = LANGUAGE_NONE;
    $node-&gt;path['pathauto'] = TRUE;
    $node-&gt;title = $title;
    $node-&gt;gsl_addressfield['und'][0]['thoroughfare'] = ucwords($address1);
    $node-&gt;gsl_addressfield['und'][0]['premise'] = ucwords($address2);

    node_save($node);
}
Use hook_node_presave($node) to check whether you are getting proper values.

Also, try drupal_form_submit() instead of node_save() for edit