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

Deelicious's avatar
Deelicious
86 posts
16 years ago
Deelicious's avatar Deelicious

I am interested in using CSVgrab on a client’s website which I do not host. I am able to use CSVgrab perfectly on my website, so I know my code and techniques are correct, but I am unable to get any output on the client’s server. I’m sure their server is lacking the necessary requirements to make CSVgrab work.

Would anyone have a suggestion as to what components are needed for CVSgrab? They have PHP 5.2.6 installed. When I run the script, I get nothing but a blank page, even with template debugging turned on.

Any help would be greatly appreciated and thank you Andrew for such a wonderful tool!

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

Deelicious,

When you say you have template debugging turned on, do you mean you have trace=”true” set in the template, or are you talking about EE debugging settings?

If you have trace=”true” set and you are seeing no output at all, it means the .csv file is not even being opened properly. So check your path. Try an absolute local filename (e.g. /home/…) or a URL (http://…) that you know works.

Also make sure the plugin is installed correctly.

       
Deelicious's avatar
Deelicious
86 posts
16 years ago
Deelicious's avatar Deelicious

Well, we’re getting somewhere! Thanks for the response, Dan. The debugging was not working correctly because the quotes needed to be replaced with proper quotes. Lastly, I’ve verified that the plugin is listed in my plugin manager.

After I run the page, which takes about 3 minutes, it gives me the following error:

TRACE: Array ( [title] => Array ( [is_custom] => 0 [field] => 1 ) [date] => Array ( [is_custom] => 0 [field] => ) [street_address] => Array ( [is_custom] => 1 [field] => 2 [id] => 27 [format] => none ) )

TRACE:

TRACE: 1 -

I’m not sure if this will help, but I noticed when I view the .csv file in my browser from my server, it displays the text in the browser window, but if I try to view the same .csv file which is located on their server, it asks me to download the file first.

Any thoughts? Thanks again.

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

TRACE: 1 -

Hmm. There should have been a number after the blank TRACE: above that indicated the file handle. I’m a little mystified that there’s nothing there. The second TRACE indicates it tried to read the first row in the .csv.

Are you uploading the .csv from a Mac? Make sure you upload it in text mode so it gets proper line endings.

I think at this point we could use a look at the template and some sample rows from the .csv. If you are willing to PM me with a URL for the .csv, I can check some things.

I’m not sure if this will help, but I noticed when I view the .csv file in my browser from my server, it displays the text in the browser window, but if I try to view the same .csv file which is located on their server, it asks me to download the file first.

That just has to do with Mime types sent by the webserver - it doesn’t indicate a problem.

       
fanderson's avatar
fanderson
883 posts
16 years ago
fanderson's avatar fanderson

In trying to upload a csv file I get the following error:

Fatal error: Call to undefined function mb_convert_encoding() in /home/ecmadmin/public_html/new/ecm/plugins/pi.csvgrab.php on line 231

Please advise. Thanks.

       
Dan Halbert's avatar
Dan Halbert
93 posts
16 years ago
Dan Halbert's avatar Dan Halbert
In trying to upload a csv file I get the following error:
Fatal error: Call to undefined function mb_convert_encoding() in /home/ecmadmin/public_html/new/ecm/plugins/pi.csvgrab.php on line 231
Please advise. Thanks.

Hi Forrest,

Your webhost has not enabled the “mbstring” extension (multibyte character handling) for PHP, so you need to ask them to do that. Depending on whether it’s Windows, or some flavor of Linux, there are different things they need to do, but they should know what to do. They may need to rebuild php, do a “yum install php-mbstring”, uncomment a line with mb_string.dll listed, etc.

       
fanderson's avatar
fanderson
883 posts
16 years ago
fanderson's avatar fanderson

Dan, Thank you for the excellent sleuthing skills. I’ll contact the host right away.

       
fanderson's avatar
fanderson
883 posts
16 years ago
fanderson's avatar fanderson

Dan, the host updated the server and mbstring is now enabled. I tried to upload a new csv file and the page came back blank with no new files added. I have attached a copy of the file and the code I am using to upload.

Please advise. Thanks.

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

Hi Forrest,

I see two problems. In your template:

use="1|3|4|5|6|7|8|9|10|11|12|13|14|15|16"
fields="cd2|category|aiff_44|wav_44|aiff_48|wav_48|mp3_128|mp3_320|length|track_description|keywords|styles|instrumentation|tempo|vocals|composers"

There are 15 numbers in the use attribute, but 16 fields listed in the fields attribute. The number of values in the attributes must match, or else CSVgrab will fail silently.

The other problem is in your .csv file. It looks good in that it has linefeed line endings, but the last line does not have a linefeed at the end.

       
fanderson's avatar
fanderson
883 posts
16 years ago
fanderson's avatar fanderson

Dan,

I added the additional column number (2) and get the following error:

Notice: Undefined index: id in /home/ecmadmin/public_html/new/ecm/plugins/pi.csvgrab.php on line 331 Notice: Undefined index: id in /home/ecmadmin/public_html/new/ecm/plugins/pi.csvgrab.php on line 332 Notice: Undefined index: format in /home/ecmadmin/public_html/new/ecm/plugins/pi.csvgrab.php on line 332 MySQL ERROR: Error Number: 1054

Please advise. Thanks.

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

Forrest,

So, based on your change, I think your template now has:

title="2"
category_field="2"
use="1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16"
fields="cd2|category|aiff_44|wav_44|aiff_48|wav_48|mp3_128|mp3_320|length|track_description|keywords|styles|instrumentation|tempo|vocals|composers"
unique="aiff_44"

All the field names in the fields attribute must correspond to custom fields. Those are the custom fields you want to fill with data. You don’t have to use all the columns if you don’t want.

But you are using column 2 as a title and category. So my guess is that you don’t have a custom field with the name “category”. If that is the case, drop column 2 and its corresponding field from use and fields:

use="1|3|4|5|6|7|8|9|10|11|12|13|14|15|16"
fields="cd2|aiff_44|wav_44|aiff_48|wav_48|mp3_128|mp3_320|length|track_description|keywords|styles|instrumentation|tempo|vocals|composers"
       
fanderson's avatar
fanderson
883 posts
16 years ago
fanderson's avatar fanderson

All fixed. Thanks.

       
mooo's avatar
mooo
168 posts
16 years ago
mooo's avatar mooo

This plugin was tremendously helpful to me. The only thing that I’m struggling with is for items in my .csv that have more than one category. I did use the category_delimiter=”SPACE” parameter, but it didn’t actually create separate categories for each item within the specified field.

Here’s the code for the “go” template:

{exp:csvgrab url="http://clientsite.com/no_resources.csv"
    delimiter=","
    encloser="QUOTE"
    weblog="12"
    skip="1"
    category_group="4"
    title="2"
    category_field="11"
    use="1|2|3|4|5|6|7|8|9|10|12|13|13|15|16|17|18|19|20|21|22|23|24"
fields="rsrc_program|rsrc_agency|rsrc_address|rsrc_city|rsrc_zip|rsrc_phone|rsrc_phone2|rsrc_contact|rsrc_email|rsrc_url|rsrc_services|rsrc_gender|rsrc_juvenile|rsrc_adult|rsrc_seniors|rsrc_other_eligibility|rsrc_fees|rsrc_funding_sources|rsrc_capacity|rsrc_grades|rsrc_st_ratio|rsrc_hours|rsrc_certifications"
    category_delimiter="SPACE”
}

I checked the .csv and the categories DO have spaces between them. What can I do to get separate categories?

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

mooo,

The category_delimiter line in your template has a non-standard double-quote at the end, after the SPACE:

category_delimiter="SPACE”

Try changing that to a regular ASCII double-quote.

       
mooo's avatar
mooo
168 posts
16 years ago
mooo's avatar mooo

oops didn’t see that. I made that change and I’m still having the same problem. I’m also getting an Undefined index: in /system/plugins/pi.csvgrab.php on line 186, although it’s importing all the data. I’m just not getting separate categories.

       
First 16 17 18 19 20 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.