Unfortunately, I am unable to get CSVGrab working. It looks like some sort of fopen security issue on the server. Here’s an excerpt from the Apache logs:
[Thu Jun 05 10:00:00 2008] [error] [client 12.34.56.789] PHP
Warning: fopen(http://255.123.456.78/testing.csv) [<a href="http://function.fopen">function.fopen</a>]: failed to open stream: A
connection attempt failed because the connected party did not properly
respond after a period of time, or established connection failed
because connected host has failed to respond.\r\n in
D:\\folder\\subfolder\\plugins\\pi.csvgrab.php on line 192
Anyone with experience on same issue?
[UPDATE Jun 09]
After further experimentation, it seems that this error and subsequent failures may be due to PHP version 5 versus 4. Everything works fine under PHP4, but fails under PHP5. All other variables the same. Only change being version of PHP running.
Got it sorted out with my host and it seems to be functioning.
However, my test import is importing the custom fields from the CSV row 1 and nothing else in any of the data rows below.
Everything is mapped correctly.
category, title, name, professional_exp, state
party, president, mr. jones, lawyer, iowa
Instead of pulling ‘president’ into the ‘title’ field in the weblog, it’s pulling ‘title’ into the ‘title’ field and so on.
{exp:csvgrab url="http://[url]/csv/officials-shortFormtest.csv"
delimiter=","
encloser="QUOTE"
weblog="17"
category_group="9"
title="2"
category_field="1"
use="3|4|5|6|7|8|9"
fields="official-name|state|current-office|family|prof-experience|congress-committees|campaign-address"
unique="official-name"
}
So, I’m not sure what is going on at this point. I resaved the CSV file and all of the sudden the test worked and all columns were imported into their correct fields in the weblog. I changed the title and official_name field for a second import test and it didn’t work - just a white screen on the go page.
Update: I think I’ve got this figured out. Turns out exporting a CSV from Excel didn’t work - CSVGrab didn’t like the file. I had to convert the XLS doc to a Numbers format then export to CSV from Numbers. Strange, but it worked. Great Plugin.
CSVGrab will write over an existing entry [WRONG: see reply #151] if the “unique” field you specify matches the same field in the existing entry. In your case, this is “official-name”. So you can reimport multiple times.
You may find it helpful to set trace=”TRUE” (actually trace=anything). This makes CSVgrab print out some info about what it is doing during the import.
I had problems importing a CSV file with about 450 rows.
Sample CSV file:
Name,Last Name,Email Address,Phone,ID,Contact ID,Owner ID,Date,In Directory?
"John Doe","Doe","john.doe@example.com","800-555-1212","","246","","2003-07-15","Y"
"Jane Doe","Doe","jane.doe@example.com","800-555-1212","","98","75","2001-12-05","N"
CSVGrab template:
{exp:csvgrab url="http://www.example.com/import/azlist_contacts.csv"
delimiter=","
encloser="QUOTE"
trace="TRUE"
site_id="1"
weblog="54"
author="1"
title="1"
date="8"
skip="1"
use="2|3|4|5|6|7|9"
fields="azlist_contact_last_name|azlist_contact_email_address|azlist_contact_phone_number|azlist_contact_ucid|azlist_contact_contact_id|azlist_contact_owner_id|azlist_contact_in_directory"
}
Import template results:
TRACE: Array ( [title] => Array ( [is_custom] => 0 [field] => 1 ) [date] => Array ( [is_custom] => 0 [field] => 8 ) [azlist_contact_last_name] => Array ( [is_custom] => 1 [field] => 2 [id] => 208 [format] => none ) [azlist_contact_email_address] => Array ( [is_custom] => 1 [field] => 3 [id] => 202 [format] => none ) [azlist_contact_phone_number] => Array ( [is_custom] => 1 [field] => 4 [id] => 203 [format] => none ) [azlist_contact_ucid] => Array ( [is_custom] => 1 [field] => 5 [id] => 206 [format] => none ) [azlist_contact_contact_id] => Array ( [is_custom] => 1 [field] => 6 [id] => 213 [format] => none ) [azlist_contact_owner_id] => Array ( [is_custom] => 1 [field] => 7 [id] => 214 [format] => none ) [azlist_contact_in_directory] => Array ( [is_custom] => 1 [field] => 9 [id] => 215 [format] => none ) )
TRACE:
TRACE: 2 -
No records were imported.
Instead of this:
TRACE:
TRACE: 2 -
you should see something like this:
TRACE: Resource id #47
TRACE: 1 - Array ( [0] => John Doe [1] => Doe ...)
The “Resource id” trace is a handle to the input file, and the second trace shows you the contents of the csv line it just read.
So it looks like it is not reading your CSV file at all. Test the URL to make sure it’s right, and assuming it works, you can instead try pointing to a local file instead of using a URL. The path is relative to the your top-level web directory (e.g. public_html/ or www/), or, use an absolute path (/home/youraccount/public_html/foo.csv) or whatever is appropriate for your webhosting account.
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.