I've seen some patches for Drupal 5, but it doesn't look like those would work for Drupal 6. Anyone have any ideas on how to import location data (address, city, state, postal code) in Drupal 6?

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Robrecht Jacques’s picture

Status: Active » Postponed (maintainer needs more info)

Do you have a sample CSV file (10 rows or something like that) you like to import?

Webster619’s picture

Not yet. I don't want to gather data in Excel until I think I can import it.

However, I would just have basic location data:

Address
City
State
Zip
Phone

as headings in the first row, and columns of data underneath. Any ideas?

Thanks

Robrecht Jacques’s picture

Status: Postponed (maintainer needs more info) » Active

In -rc4 you'll be able to import Location. That's why I wanted a CSV file to test a little, but I suppose I can make one myself.

Robrecht Jacques’s picture

Status: Active » Fixed

Fixed in CVS. Will be included in upcoming -rc4 release.

hvalentim’s picture

FileSize
315 bytes

Just installed and tried the dev version tar.gz, dated from today.

A few issues trying to import Location fields:

  1. I was never, ever able to import "Latitude" and "Longitude" (tried many different settings, a sample file used is attached); I always end up with empty values.
  2. Choosing the option "Tab Separated Values" in step 3 actually seems to implement the options from "Delimiter Separated Values" (and not the default settings for "tab sep. values") once you get to step 7 (even if you "reload" the page in step 3 and it looks OK there).
  3. You are asked twice to map "Latitude" but never "Longitude" (seems easy to fix: changing line 26 of location.inc to: 'title' => t('Longitude')

Thank You.

Robrecht Jacques’s picture

Version: 6.x-1.0-rc2 » 6.x-1.x-dev
Category: support » bug

I was never, ever able to import "Latitude" and "Longitude" (tried many different settings, a sample file used is attached); I always end up with empty values.

Thanks for the sample file. You are correct, longitude and latitude were not handled correctly. Fixed.

Choosing the option "Tab Separated Values" in step 3 actually seems to implement the options from "Delimiter Separated Values" (and not the default settings for "tab sep. values") once you get to step 7 (even if you "reload" the page in step 3 and it looks OK there).

As I mostly test with CSV file, this error had not previously occurred to me. Fixed.

You are asked twice to map "Latitude" but never "Longitude" (seems easy to fix: changing line 26 of location.inc to: 'title' => t('Longitude')

Indeed. Fixed.

Thanks for testing!

jcamfield’s picture

Robrecht - if you need more testing, I have a test site and up to ~1000 test location records I hope to import. Let me know if you have a preferred version (or just the latest dev branch ver) you'd like me to play with.

Robrecht Jacques’s picture

jcamfield: I'll release -rc4 later today. If you could play with that and create an new issue if you find problems. Note that only Location will be supported, not yet CCK Location.

kevinwalsh’s picture

as i wrote on http://drupal.org/node/207738#comment-1293396, it's looking good to me so far. i will be testing again in the next few days.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

xurizaemon’s picture

Re-opening. Installed D6 CVS just now, but CCK location field components do not appear as an option when mapping import columns to content type fields.

Edit: I see in comment #8 above that CCK Location is not supported as of RC4, but Location fields are.

jasontanner’s picture

Status: Closed (fixed) » Active

As Location CCK seems to be reasonably stable for D6 now, it would be nice if it were added to Node Import soon.

GuyPaddock’s picture

FileSize
2.23 KB

Courtesy of Red Bottle Design, LLC, please find attached an implementation of "Location CCK" support for Node Import.

Drop it into "supported/location", along-side location.inc (this implementation is independent of normal location node support).

DISCLAIMER: We wrote this to get a large import for one of our clients to work; as such, it has only been tested with our data from 900 or so records. In addition, the current implementation will not work with multiple-value location fields.

As always, your mileage may vary.

aterchin’s picture

Guy - works great, but unfortunately you don't get to set the default options ( step 6 of 8 i think). otherwise, you've got it working well if someone absolutely needs to use CCK, which actually i think is a preferred way to do stuff like this.
Very useful module, Robrecht.
(... now if they'd only get location cck working in feedapi_mapper :) )

GuyPaddock’s picture

Yeah, sorry about the lack of defaults. We have the defaults set in the content type, so that was sufficient here.

Location CCK is nice and all, but it still has a lot of quirks, especially when you hide "Country" instead of "Country name" and your map links disappear, or you enable phone support and find that it doesn't render anywhere. I think that more modules will start supporting it more when these quirks are fixed.

aterchin’s picture

agree. for now i'm just using the node location settings. there are ways of getting the data in there if and when i ultimately move my location data into cck. if and when.

ndm’s picture

FileSize
2.79 KB

Hello, i have problem with coordinates so i had a router in the end process to dispatch latitude and longitude.

Now if you want have coordinates, you must map a col with "latitude;longitude" and it's work.

Chris Charlton’s picture

I'd like to see this make RC5, with defaults. :)

betamos’s picture

I didn't know if I should start a new issue or not, but i have found a minor bug while importing location data:

To recreate the bug, you would probably need something like the following:

  1. A node type with location fields latitude and longitude.
  2. GMap module enabled (maybe you need gMap location module as well, don't remember).
  3. A node template which uses the function gmap_simple_map().
  4. In that function's arguments, put $node->location['latitude'] (and the same for longitude)
  5. Create a test node, fill in latitude and longitude. Save. Make sure it looks good on full node view.
  6. A CSV-file with columns for latitude and longitude.
  7. Import that CSV-file. While previewing, the map will center over Africa somewhere and put a dot right in the ocean, which makes no sence, since nobody cares about Africa.

This bug only occurs while in preview mode, the import itself works like a charm. I looked it up a little further, and it seems that $node->location is not even available while importing, which explains the mystic Africa-thingy. It appears that if no coordinates are given, it defaults to just below Ghana in the ocean, which only happens to have the coordinates 0.000000,0.000000, in the origo of the earth, right on the Equator :)

However, the almost exact same array $node->locations (ending with an "s") is available in import mode perfectly fine.

To sum it up: Node import does not acquire the $node->location array through node template while in preview mode.

landry’s picture

to comment #13:

location_cck.inc worked fine for me, although a minor nit : in fields mapping selection, it only shows 'allowed' fields, not 'required' ones.
I'll change the check

if ($formFields[$locationFieldName]['collect'] == 1)

to be also valid if the value is 2 (field is required).

Ryan Palmer’s picture

Status: Needs work » Needs review
FileSize
4.72 KB

Didn't realize this was in process. Our take at Location CCK support inc file attached. Same instructions apply: remove the .txt extension, drop it into supported/location. I would have rolled a patch but I'm unable to "cvs add" the new file.

File attached adheres to Drupal coding standards whereas #13/17 are lacking.

Summit’s picture

Title: Import Locations in Drupal 6 » Support CCK Locations
Category: bug » feature
Status: Active » Needs review

Subscribing, which version will be implemented, or is it possible to have best of all files here attached?
greetings, Martijn

Robrecht Jacques’s picture

Status: Needs review » Fixed

Committed #21 to CVS. Will be included in -rc5 release.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

Chris Charlton’s picture

I see this error filling up my error logs. This is probably one of the earlier patches above.

PHP Warning: Call-time pass-by-reference has been deprecated; sites/all/modules/contrib/node_import/supported/location/location_cck.inc on line 19

hutch’s picture


PHP Warning: Call-time pass-by-reference has been deprecated; sites/all/modules/contrib/node_import/supported/location/location_cck.inc on line 19

Is there a '&' immediately before a variable on line 19? If so remove it and try again

mstrelan’s picture

Committed #21 to CVS. Will be included in -rc5 release.
When will rc5 be released?

mstrelan’s picture

FileSize
4.91 KB

Hi

Using location_cck.inc from #21 I found that if you have two different CCK Location fields on the one content type you cannot distinguish between them when mapping fields. For example, if you have street address and postal address you just see Street, Street, Suburb, Suburb, Postcode, Postcode etc.

The attached file displays it as Street Address Street, Postal Address Street, Street Address Suburb, Postal Address Suburb, Street Address Postcode, Postal Address Postcode.

Summit’s picture

Hi,
Could you file a patch of it, then it is easier for the maintainer to commit this change.
Thanks!
greetings, Martijn

colan’s picture

Status: Closed (fixed) » Needs work

Let's get a patch file for this so that we can test it! I'll produce one eventually unless someone else does first.

patchak’s picture

Hey there, I get WSOD when using the file from #28 ...using with the latest dev. Maybe a patch would help to test indeed?

mbabayan’s picture

Applied the patch; I am mapping Street Address, City, Postal Code and Phone, and I only get Postal Code imported - the rest of the fields are empty on the imported nodes.
Other CCK fields (outside of location) are mapped fine.
Where do I need to look ?

Thanks,
MB

lolmaus’s picture

Subscribing

burgs’s picture

I just used #28 (renamed obviously to .inc) and it worked fine for an import of over 300 rows. I was just importing into Street, Postal code and Telephone for a multi value cck location field.

Thanks!!

Location 6.x-1.0-rc4
Pressflow 6

nemchenk’s picture

FileSize
1002 bytes

Found a small bug in location_cck.inc -- when creating a new Location CCK field for a content type, if you do not fill out the Configure screen for that field, location_cck.inc will throw the following:

"Fatal error: Cannot use string offset as an array in .../modules/node_import/supported/location/location_cck.inc on line 30"

The patch below (against node_import-DRUPAL-6--1 from CVS) checks to see if $settings['location_settings']['form'] exists before trying to access settings underneath it.

nemchenk’s picture

FileSize
347 bytes

Similar to #28, I have two Location CCK fields for my user Content Profile -- one "Home" and one for "Work". The patch below labels them with whatever label the field has assigned, for example "Home: Postal Code" or "Work: Location name". Patch is against the DRUPAL-6--1 branch in CVS.

colan’s picture

Stephen Scholtz’s picture

Man, I haven't been able to get this to work yet.

I'm running:
Drupal 6.19
Location CCK 3.1
User Import 2.3
Content Profile 1.0
Node Import Dev (July 11, 2010)

The Location fields are showing on the import screen and I can map them, but nothing actually gets into my database tables it seems.

Suggestions? I'll have to dig further... apologies if this turns out to be some other modules problem. :P

PS - sample import data:

Columns: User name, email, birthday, address 1, address 2, city, province, postal code, country, phone number, gender, what are you hoping to do here, do here details, how did you find out about the site, how found out details, roles

"GEORGE POPE","me@email.com","1967-02-20","Address 1","Address 2","Richmond","BC","Postal Code","ca","555-123-1234","male","other","Blah blah","other","Word of Mouth","User - Alumni,User - Imported from Old Site"

webankit’s picture

+1

bkat’s picture

Version: 6.x-1.x-dev » 6.x-1.0

I'm having this exact same problem with 6.x-1.0 on drupal-6.20. Everything looks great on setup with my Location CCK field but nothing is getting put in the database.

bkat’s picture

There is an issue in the Location module where CCK Location does not save if the Node Locations module is enabled. You have to choose one or the other.

http://drupal.org/node/906968

That was part of my problem with CCK Location not being saved.

TechNikh’s picture

+1 subscribing..

goose2000’s picture

Hi, subscribing. I have basic Location CCK added to my 'content profile' type. When I tried to upload users + their profile data (address info in this instance) only the zip field would get updated or saved.

log would report:

location 10/06/2011 - 12:38pm Deleting unreferenced location with LID 59.
location 10/06/2011 - 12:38pm Deleting unreferenced location with LID 58.

TheDanScott’s picture

I am also having the issue mentioned in #43 - only postcode comes through and messages in the log about deleting unreferenced locations.

I have the following Location CCK fields enabled:
Country,
Street,
City,
State / Province,
Postal Code

Steve Dondley’s picture

Category: feature » bug
FileSize
3.09 KB

Here's a patch to address the problem mentioned i comment #43 and #44 above. It's just a preliminary patch for review so I left in the debug code.

This patches the content_profile.inc file in the "supported" directory within the user import module.

By the way, that "rdpw" function in the debug code is a home-rolled print statement we use for our own in-house debugging. It should be replaced with the corresponding function in the devel module (which slips my mind at the moment).