We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Plugin: CSVGrab

Development and Programming

Andrew Weaver's avatar
Andrew Weaver
206 posts
about 17 years ago
Andrew Weaver's avatar Andrew Weaver

Try adding an encloser=”QUOTE” parameter anyway. The value is treated as optional by the PHP function.

Andrew

       
Kev-O's avatar
Kev-O
50 posts
about 17 years ago
Kev-O's avatar Kev-O

Yep, that fixed it, thanks alot for the quick response.

       
Sue Crocker's avatar
Sue Crocker
26,054 posts
about 17 years ago
Sue Crocker's avatar Sue Crocker

Andrew, what about a single quote? Is that possible?

       
Andrew Weaver's avatar
Andrew Weaver
206 posts
about 17 years ago
Andrew Weaver's avatar Andrew Weaver

I think you can just use a single quote in the encloser (eg, encloser=”’”) but let me know if this does not work.

Andrew

       
R.BIRD's avatar
R.BIRD
41 posts
about 17 years ago
R.BIRD's avatar R.BIRD

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.

       
Paul B's avatar
Paul B
241 posts
16 years ago
Paul B's avatar Paul B

Can anyone tell me what this means?

Fatal error: Call to undefined function mb_convert_encoding() in /home/[path removed]/plugins/pi.csvgrab.php on line 231

I see this error when I attempt to view the go page to “activate” the plugin.

I can’t get CSVGrab working.

       
Ingmar Greil's avatar
Ingmar Greil
29,243 posts
16 years ago
Ingmar Greil's avatar Ingmar Greil

I think it indicates missing Unicode support (mb = multibyte) on your host. Ask them about it.

       
Paul B's avatar
Paul B
241 posts
16 years ago
Paul B's avatar Paul B

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.

       
Dan Halbert's avatar
Dan Halbert
93 posts
16 years ago
Dan Halbert's avatar Dan Halbert

Could you post your template?

       
Paul B's avatar
Paul B
241 posts
16 years ago
Paul B's avatar Paul B
{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.
       
Paul B's avatar
Paul B
241 posts
16 years ago
Paul B's avatar Paul B

Question: Will the plugin allow for “updating” an original imported list? Or, do entries have to be deleted and re-imported to update information? (if, for example, we had multiple changes to multiple entries)

       
Dan Halbert's avatar
Dan Halbert
93 posts
16 years ago
Dan Halbert's avatar Dan Halbert

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.

       
kirkaracha's avatar
kirkaracha
273 posts
16 years ago
kirkaracha's avatar kirkaracha

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","[email protected]","800-555-1212","","246","","2003-07-15","Y"
"Jane Doe","Doe","[email protected]","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.

       
Dan Halbert's avatar
Dan Halbert
93 posts
16 years ago
Dan Halbert's avatar Dan Halbert

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.

       
kirkaracha's avatar
kirkaracha
273 posts
16 years ago
kirkaracha's avatar kirkaracha

I changed it to an absolute path and it loaded the data into the template, but it didn’t import the data into the database.

       
First 8 9 10 11 12 Last

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.