Php has a nice function to get data from a CSV: http://us3.php.net/manual/en/function.fgetcsv.php $handle = fopen("test.csv", "r"); while (($data = fgetcsv($handle)) !== FALSE) { // $data is an array of entries from that row. $node->field_data[0]['value'] = $data[0]; $node->field_other_data[0]['value'] = $data[1]; $node_save($node); } Brian Neil Hastings wrote:
That's easier then what I did. Using http://code.google.com/p/parsecsv-for-php/
Example code: function opcerts_import_person() { //add person $csv = new parseCSV; $csv->auto('/var/www/import.csv');
foreach ($csv->data as $key => $row) { //get the nid if the person already exists $nid = opcerts_person_check_emp_id($row['emp_id']); if (!$nid) { $person = new stdClass;
//add person $person->uid = 1; $person->type = 'person'; $person->field_last_name[0]['value'] = $row['l_name']; $person->field_first_name[0]['value'] = $row['f_name']; $person->field_emp_id[0]['value'] = $row['emp_id']; $person->field_position[0]['value'] = $row['title_tid']; $person->field_unit[0]['value'] = $row['unit_tid']; $person->field_middle[0]['value'] = $row['m_name']; $person->field_other_name[0]['value'] = $row['o_name']; } else { //add the unit to the person $person = node_load($nid); array_unshift($person->field_unit, array('value' => $row['unit_tid'])); } node_object_prepare($person); node_save($person); unset($person); } }
Cheers, Neil http://code-dreamers.com
On Thu, Jul 30, 2009 at 1:19 PM, Kyle Mathews <mathews.kyle@gmail.com <mailto:mathews.kyle@gmail.com>> wrote:
Feedapi + parser_csv + feed element mapper + cck
http://drupal.org/project/feedapi http://drupal.org/project/parser_csv http://drupal.org/project/feedapi_mapper
Kyle
Research Assistant Entrepreneurship and Technology Center @ BYU kyle.mathews2000.com/blog <http://kyle.mathews2000.com/blog>
2009/7/30 Gastón Pablo Pérez <gpperez@gmail.com <mailto:gpperez@gmail.com>>
Hi!
I would like implement a functionality in a web site for able to upload an excel file, with a determined format, and then, I want to generate nodes with this information. Exists a module or a medium to do that? or how can i insert data into drupal database from an excel file?
thanks a lot
-- "La perseverancia es un árbol de raíces amargas, pero de frutos muy dulces."
Gastón Pablo Perez Email:gpperez@gmail.com <mailto:Email%3Agpperez@gmail.com>