Hi Drupal experts

Do anyone know any module or any clue how create a module that can import or export
.cvs or spreadsheet files from a Drupal database?

Best regard

Phillip

Comments

geodaniel’s picture

For Drupal 5 (not sure there'll be anything for 7.x yet, and neither of these seem to have official 6.x releases yet) you could try Node Import to import from CSV and Views Bonus Pack to export.

dnewkerk’s picture

Not sure what you're asking exactly so this might not be what you want.

Here's an SQL query I used to import data from my old database into a table from a CSV file (this table and fields should already exist):

LOAD DATA LOCAL INFILE 'users.csv'
INTO TABLE oldsite_users
FIELDS TERMINATED BY ','
ENCLOSED BY '"'
LINES TERMINATED BY '\n'
(user_id, username, password, email, signature, signature_hash, join_date, last_activity, last_visit, timezone, avatar, blocked_status, name, homepage, msn, aim, icq, yim, location, title);

I imported first this way instead of directly into Drupal because I needed to run some cleanup on the old data first (after that I inserted the data into Drupal). If your data is already exactly ready to go into Drupal, you could import directly into the table of Drupal's, and replace the field names with all of those of the Drupal table you're importing into.

See: http://www.davidnewkerk.com/book/48

-- David
absolutecross.com
[new guide/lesson in progress: Creating a CCK and Views powered Drupal site - feedback welcome]