Any ways to bulk create suburb list taxonomy terms [D7] ?

Events happening in the community are now at Drupal community events on www.drupal.org.
gilzero's picture

Greeting OZ Drupalers. :)

I created a Vocabulary called 'Victoria Suburb', and need to create all suburbs as terms in the Vocabulary.

It would be time-consuming to add each term one by one.

Are there any better approaches?

Thanks!

Comments

With or without code?

rcross's picture

Unless you want to break open a bit of code, I've used Taxonomy Manager to paste in a long list of things like that. http://drupal.org/project/taxonomy_manager

feeds

jrobens's picture

Feeds looks like the best. We had success in d6 with qadrawdi. There are a number of csv/spreadsheet import modules too. Currently playing with sheetnode but for just a once off import feeds seems like the go.

Are you trying to grab from openstreetmap? Pull from here http://open.mapquestapi.com/xapi/api/0.6/node[place=suburb][bbox=15.807,45.761,16.18,45.875] and import like this http://drupal.stackexchange.com/questions/3011/feeds-mapping-api.

I guess you want the list in the database, rather than using a location service because of typeahead?

Try this

php approach

AndrewBoag's picture

Certainly recommend looking at Taxonomy Manager or the other module to do what you are after.

However, writing the php isn't too tricky either.

Here is a snipped that I use to populate a list of countries into a vocabulary. This even has some hierarchy in there so you can see how parent-child relationships work. It's all pretty sensible.

NOTE: this assumes you have already created the vocabulary and you know the VOCABID (vid)

  $t = new StdClass();
  $t->vid = $VOCABID;
  $t->weight = 0;
  $t->name = 'Eastern Europe';
  taxonomy_term_save($t);

  $list = array('Russia', 'Belarus', 'Ukraine');
  foreach ($list as $country) {
    $c = new StdClass();
    $c->vid = $VOCABID;
    $c->name = $country;
    $c->parent = $t->tid;
    taxonomy_term_save($c);
  }

  $t = new StdClass();
  $t->vid = $VOCABID;
  $t->weight = 1;
  $t->name = 'Central Europe';
  taxonomy_term_save($t);

  $list = array('Estonia', 'Latvia', 'Lithuania', 'Poland', 'Czech', 'Slovakia', 'Hungary');
  foreach ($list as $country) {
    $c = new StdClass();
    $c->vid = $VOCABID;
    $c->name = $country;
    $c->parent = $t->tid;
    taxonomy_term_save($c);
  }

This doesn't include the code to create a vocab programatically, which may or may not be required. Sing out if you need that I can I dig it up somewhere.

This is cool too if you use

MickC's picture

This is cool too if you use Location http://drupal.org/project/location_taxonomize

MickC that is a cool module

chaloum's picture

MickC that is a cool module

EDMEDiA Australia

http://drupal.org/project/com

barwonhack's picture

http://drupal.org/project/commerce
plays nice with ...
http://drupal.org/project/addressfield
which (allegedly) plays nice with ...
http://drupal.org/project/location_taxonomize

BUT, I just raided wikipedia and created them manually (for Melbourne) over a few nights with a beer or five handy and the Drive soundtrack playing in te background...

IMHO you need to craft the entries to your requirements.

An issue worth considering is proximity. Boundaries are somewhat arbitrary lines on a map and that distinction isn't always valid. EG: When you say Melbourne, do you mean Melbourne CDB, Melbourne Inner Suburbs or perhaps Melbourne Airport as a gateway to Victoria?

Not all suburb names have postcodes and some suburbs occupy two municipalities. An Inner-Western Suburb, may also fit within the Inner-Northern Grouping. Outside the major capital cities, do suburbs matter so much, and to whom (a local may have a vastly different view to a potential visitor?

Further, how are you going to use the terms? Application through, say, Openlayers and Views may make your taxonomy virtually irrelevant if, for example, your nodes are geocoded and "Zoom To" or Proximity functions are being used.

Australia

Group categories

Location

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds:

Hot content this week