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

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

I am late to the game here but still willing to play.

I have installed the plugin version 0.2.1 and followed all the instructions but do not get any results to show up.

I am using a .csv file and I have tried, QUOTE, SPACE and just plain old “” with nothing in between the “.

My code is as follows:

{exp:weblog:entries weblog="csv_test" limit="10"}

<dt>{title}</dt>
<dt>{categories backspace="9"}{category_name} • {/categories}</dt>
<dd>{golf_addr}</dd>
<dd>{golf_city}</dd>
<dd>{golf_state}</dd>
<dd>{golf_zip}</dd>
<dd>{golf_phone}</dd>

{paginate}
<div class="paginate">
<span class="pagecount">Page {current_page} of {total_pages} pages</span>  {pagination_links}
</div>
{/paginate}

{/exp:weblog:entries}

and

{exp:csvgrab url="http://www.grandchestermeadows.com/docs/test.csv"
    delimiter=","
    encloser="SPACE"
    weblog="5"
    skip="2”
    category_group="3"
    title="1"
    category_field="2"
    use="3|4|5|6|7|8"
    fields="golf_addr|golf_city|golf_state|golf_zip|golf_phone"
    unique="golf_phone"
}

The display does work because the two manual entries I made to the weblog show up.

Any clues what I am missing here?

Thanks.

       
Dan Halbert's avatar
Dan Halbert
93 posts
16 years ago
Dan Halbert's avatar Dan Halbert
{exp:csvgrab url="http://www.grandchestermeadows.com/docs/test.csv"
    delimiter=","
    encloser="SPACE"
    weblog="5"
    skip="2”
    category_group="3"
    title="1"
    category_field="2"
    use="3|4|5|6|7|8"
    fields="golf_addr|golf_city|golf_state|golf_zip|golf_phone"
    unique="golf_phone"
}

Forrest,

I downloaded your test.csv file and looked at it. It contains only carriage returns (\r), no linefeeds (\n). So it is a Mac text file, with Mac line endings, which PHP does not handle. You have to upload it in text mode so that the line endings will be converted to something that PHP understands. Or edit it locally and convert the “\r”s to “\r\n” or “\n”. That is your main problem.

A note: encloser=”SPACE” is really weird. That means that spaces are acting as quotes. encloser=”QUOTE” is fine and the quotes are then optional.

Dan

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

Dan,

Thanks for the reply. I changed it to a txt file and set delimeter=”TAB” but I am still not getting the data into the weblog. Is there something else I am missing?

Forrest

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

I see it is now test.txt.

How are you uploading to your website? Are you using Transmit? If so, look here for how to force Transmit to use text mode.

Go back to the CSV file, and set delimiter=”,”. But upload it in “Text mode”.

Also your file is chopped off at the end. The last line does not have a newline at the end of it.

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

Dan,

I changed back to test.csv, added a return to the last line and uploaded (yes you were correct) using Transmit. I changed the mode to ASCII (Text). I also changed the file in go to test.csv. My other settings are:

{exp:csvgrab url="http://www.grandchestermeadows.com/docs/test.csv"
    delimiter=","
    encloser="QUOTE"
    weblog="5"
    skip="2”
    category_group="3"
    title="1"
    category_field="2"
    use="3|4|5|6|7|8"
    fields="golf_addr|golf_city|golf_state|golf_zip|golf_phone"
    unique="golf_phone"
}

Alas still no go. I am really not trying to try your patience, but I know we are very close to a solution. Thanks for bearing with me.

       
Andrew Weaver's avatar
Andrew Weaver
206 posts
16 years ago
Andrew Weaver's avatar Andrew Weaver

Hi Forrest,

You have 6 columns in the use parameter and 5 in the fields parameter.

  • I really need to improve the error catching, sorry *

Andrew

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

Hi Forrest,

You have use=”3|4|5|6|7|8” (six fields), but only five fields are in fields=”golf_addr|golf_city|golf_state|golf_zip|golf_phone”. I think you don’t mean to have the “|8”. If these don’t match up, CSVgrab fails silently.

Set trace=”true” which will give you more debugging output. That will help if there are further problems.

Also your latest CSV file seems to have too many columns in it, though I don’t think that should cause a problem.

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

That last item did the trick. The data all imported correctly and I have success. I love happy endings. Thank you so much for your time and assistance on this.

Forrest

       
Andrew Weaver's avatar
Andrew Weaver
206 posts
16 years ago
Andrew Weaver's avatar Andrew Weaver

Also, the second quote in the skip parameter is a curly quote ” rather than a straight ” (you have to look very carefully to see it). If you’ve copied and pasted this line from somewhere, try typing it out manually.

Andrew

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

Yes, I caught that one. I copied it from the tutorial on the website. With that out and the numbers matching I am in good shape. Thanks for an exceptionally useful plugin.

Forrest

       
Andrew Weaver's avatar
Andrew Weaver
206 posts
16 years ago
Andrew Weaver's avatar Andrew Weaver

Thanks to Dan for his help supporting this plugin. I really need to improve the error handling…

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

I second the thanks to Dan for his help supporting the plugin. It really makes a difference.

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

I’m back with what I hope is just one more question.

Since the trial run was a success last night, I am back with the real production run. I have mirrored everything I learned yesterday and have the following code:

{exp:csvgrab url="http://www.editorschoicemusic.com/new/upload.csv"
    delimiter=","
    encloser="QUOTE"
    weblog="1"
    category_group=""
    skip="1"
    title="2"
    use="1|3|4|5|6|7|8|9|10|11|12|13|14|15|16"
    fields="music_cd|aiff_44|wav_44|aiff_48|wav_48|mp3_128|mp3_320|length|track_description|keywords|styles|instrumentation|tempo|vocals|composers"
    unique="aiff_44"
}

When I run this page I get the following error:

The following tag has a syntax error: {exp:csvgrab} Please correct the syntax in your template.

I don’t need a category for these particular entries so that is blank on purpose.

Any suggestions?

Thanks, Forrest

       
Andrew Weaver's avatar
Andrew Weaver
206 posts
16 years ago
Andrew Weaver's avatar Andrew Weaver

The error you are getting suggests that the plugin is not even getting run and that there is a problem in the template.

You can probably leave the category_group parameter out completely - that might be the problem.

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

Andrew,

A little oversight there. I forgot that I was working on another domain. I got the plugin installed and the import went almost perfectly. It skipped one field - music_cd, which brings up a question:

Is there a problem with the sequence of the fields? For example. In the spreadsheet the music_cd is the first column and title is the second, however, in the weblog entry form, naturally the title is first followed by the url_title and then the music_cd. Also, in the music_cd field, it is a dropdown list.

Your thoughts?

Thanks,

Forrest

       
First 13 14 15 16 17 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.