12 of 14
12
Plugin: CSVGrab
Posted: 09 October 2008 08:57 PM   [ Ignore ]   [ # 199 ]  
Grad Student
Rank
Total Posts:  67
Joined  10-18-2002

Hi timj - questions and suggestions:

Set trace=“true” in your template for more debugging help.

Could you post your CSVgrab template? Could you post some sample data and sample output? What happens if you put a different first row in the data file?

Double-check the custom field names to make sure there are no errors.

Did you upload the csv file from a Mac? If so, did you make sure to do it in text mode so the line endings are OK?

Profile
 
 
Posted: 09 October 2008 09:15 PM   [ Ignore ]   [ # 200 ]  
Lab Assistant
RankRank
Total Posts:  117
Joined  04-22-2002
Dan Halbert - 09 October 2008 08:57 PM

Did you upload the csv file from a Mac? If so, did you make sure to do it in text mode so the line endings are OK?

That was it.  Thanks!

Profile
 
 
Posted: 24 October 2008 10:09 AM   [ Ignore ]   [ # 201 ]  
Grad Student
Rank
Total Posts:  41
Joined  05-15-2008

This plugin has proven to be helpful time and time again - thanks!

One question I have is whether there’s any way possible to import data from a custom field based on a weblog relationship. Might be a long shot, but if there’s a way or if someone has a suggestion I’d be happy to give it a shot.

Thanks,
Manoj

Profile
 
 
Posted: 25 October 2008 08:57 PM   [ Ignore ]   [ # 202 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  863
Joined  01-07-2003

{exp:csvgrab url="http://www.domain.org/acup.txt"
    
delimiter="TAB"
    
encloser=""
    
site_id="1"
    
weblog="14"
    
category="151"
    
author="3"
    
title="3"
    
use="1|2"
    
fields="dir_name|dir_phone1"
    
trace="true"
}

I’m stumped!

I’ve tried .CSV and TAB (.txt) as in this example.
Working from a Mac (yes transmit is forcing text for the mode)
My output looks like this.

TRACE: Array ( [title] => Array ( [is_custom] => 0 [field] => 3 ) [date] => Array ( [is_custom] => 0 [field] => ) [dir_name] => Array ( [is_custom] => 1 [field] => 1 [id] => 18 [format] => none ) [dir_phone1] => Array ( [is_custom] => 1 [field] => 2 [id] => 19 [format] => none ) [dir_phone2] => Array ( [id] => 20 [format] => none ) [dir_url] => Array ( [id] => 21 [format] => none ) [dir_email1] => Array ( [id] => 22 [format] => none ) [dir_email2] => Array ( [id] => 23 [format] => none ) [dir_summery] => Array ( [id] => 24 [format] => none ) [dir_services_1] => Array ( [id] => 25 [format] => xhtml ) [dir_image] => Array ( [id] => 26 [format] => none ) [dir_services_2] => Array ( [id] => 27 [format] => xhtml ) [dir_services_3] => Array ( [id] => 28 [format] => xhtml ) [dir_tags] => Array ( [id] => 29 [format] => none ) )

The file is attached if that helps (I’ll remove it once I solve this puzzle).

I’ve checked file permissions and even tried a server path vs. url like in this example.

Anyone with a fresh set of eyes see what I’m overlooking here?

I’m really excited about the possibilities of this but I’ve got to get it working first.

Thanks.

File Attachments
acup.txt  (File Size: 1KB - Downloads: 20)
 Signature 

 NetRaising is a member of the EE Pro Network

Profile
 
 
Posted: 25 October 2008 09:33 PM   [ Ignore ]   [ # 203 ]  
Grad Student
Rank
Total Posts:  67
Joined  10-18-2002

Hi Kurt, if you don’t see a line that looks something like this:

TRACE: Resource id #49


in the TRACE output, then it is not even opening the file. What was the absolute file path you gave? It should be the actual filepath, such as you would use if you ssh’d into the server and wanted to access the file. If you can ssh in, make sure you can cat the file with that path.

Can you turn on PHP error reporting to see what’s going wrong with the file open or fetch? That info may also be in the server Apache error logs.

Profile
 
 
Posted: 25 October 2008 11:50 PM   [ Ignore ]   [ # 204 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  863
Joined  01-07-2003

OK. . . we can see the file

TRACE: Resource id #51

That turned out to be a permissions issue (up loaded that file too many times and lost track).

{exp:csvgrab url="/var/www/vhosts/domain.org/httpdocs/acup.txt"

But it doesn’t seem to matter what path I use to get there (the URL or the sever path), its a no-go.

Ahh. . .  from the sever log:

[Sat Oct 25 23:17:24 2008] [error] [client 00.000.000.000] PHP Warning:  fgetcsv() [<a href=‘function.fgetcsv’>function.fgetcsv</a>]: enclosure must be a character in /var/www/vhosts/domain.org/httpdocs/system/plugins/pi.csvgrab.php on line 202

At last a clue. It doesn’t appear to like my enclosure’s character. . .

AND THE ANSWER IS:

encloser=“SPACE”

Yeeee Haaaa. . . .

Thanks for the help Dan!

 Signature 

 NetRaising is a member of the EE Pro Network

Profile
 
 
Posted: 26 October 2008 08:06 AM   [ Ignore ]   [ # 205 ]  
Grad Student
Rank
Total Posts:  67
Joined  10-18-2002
Kurt Deutscher - 25 October 2008 11:50 PM

Yeeee Haaaa. . . .

Great! You’re welcome.

The encloser used to be optional, I think, in some previous version of PHP, but has now become required. However, the actual data is not required to have an encloser. If the encloser is present, then it will be used to quote the data so that you can have delimiter characters inside. So if you have

encloser="SPACE"
delimiter="TAB"


then you are saying you may have data like this:

123<tab>456<tab><space>abc<tab>def<space><tab>xyz


That would break into fields like this. Notice that the third field has an embedded tab as part of the data:

"123"    "456"    "abc<tab>def"    "xyz"


Since you are using tab-delimited data, it may be safer to use

encloser="QUOTE"

or some character you’re not expecting at all, just in case one of your fields starts with a space. If it did, that field eat up the rest of the characters, including the following tabs, until there awas another space.

Profile
 
 
Posted: 29 October 2008 11:32 PM   [ Ignore ]   [ # 206 ]  
Grad Student
Avatar
Rank
Total Posts:  59
Joined  08-07-2008

{exp:csvgrab url="http://mine.com/sbs.csv"
    
delimiter=","
    
encloser="QUOTE"
    
skip="1”
    author="
1"
    site_id="
4"
    weblog="
9"
    category_group="
9"
    title="
3"
    category_field="
1"
    use="
1|3|4|5|6|7|8"
    unique="
busdir_cat, busdir_address"
fields="
busdir_cat|busdir_comp_name|busdir_address|busdir_city|busdir_state|busdir_zip|busdir_phone"
}

Just wanted to make sure that

unique="busdir_cat, busdir_address"

Won’t import any items with the same busdir_cat AND busdir_address right?  It’s not an OR comparison..?

If busdir_cat and busdir_address both matched another entry then the item wont be imported, right? 

Kevin

Profile
 
 
Posted: 30 October 2008 02:08 PM   [ Ignore ]   [ # 207 ]  
Grad Student
Rank
Total Posts:  67
Joined  10-18-2002
Kevin Althaus - 29 October 2008 11:32 PM

Won’t import any items with the same busdir_cat AND busdir_address right?  It’s not an OR comparison..?

If busdir_cat and busdir_address both matched another entry then the item wont be imported, right?

Yes, they both have to match, so it’s AND. In CSVgrab, an SQL query is generated with equality checks grouped together with AND’s.

Profile
 
 
Posted: 30 October 2008 02:13 PM   [ Ignore ]   [ # 208 ]  
Grad Student
Avatar
Rank
Total Posts:  59
Joined  08-07-2008

Thanks Dan!

Profile
 
 
Posted: 03 November 2008 10:40 AM   [ Ignore ]   [ # 209 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  422
Joined  12-15-2005

edit: i have fixed my own problem. please move along. nothing to see here. red face

 Signature 

System Info: Production

EE Version:  1.66
Build
:       20081114
PHP Version
: 5.2.5

Profile
 
 
Posted: 12 November 2008 02:44 PM   [ Ignore ]   [ # 210 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  363
Joined  02-25-2008

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} &#8226; {/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.

 Signature 

Rouviere Media — Building Expression Engine Sites. Based in Raleigh, NC Area .

Profile
 
 
Posted: 12 November 2008 03:19 PM   [ Ignore ]   [ # 211 ]  
Grad Student
Rank
Total Posts:  67
Joined  10-18-2002
Forrest Anderson - 12 November 2008 02:44 PM

{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

Profile
 
 
Posted: 12 November 2008 03:34 PM   [ Ignore ]   [ # 212 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  363
Joined  02-25-2008

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

 Signature 

Rouviere Media — Building Expression Engine Sites. Based in Raleigh, NC Area .

Profile
 
 
Posted: 12 November 2008 03:40 PM   [ Ignore ]   [ # 213 ]  
Grad Student
Rank
Total Posts:  67
Joined  10-18-2002

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.

Profile
 
 
Posted: 12 November 2008 03:57 PM   [ Ignore ]   [ # 214 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  363
Joined  02-25-2008

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.

 Signature 

Rouviere Media — Building Expression Engine Sites. Based in Raleigh, NC Area .

Profile
 
 
Posted: 12 November 2008 04:06 PM   [ Ignore ]   [ # 215 ]  
Lab Assistant
RankRank
Total Posts:  165
Joined  12-21-2005

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

 Signature 

Andrew Weaver — brandnewbox.co.uk


Member of EE Professional Network · More plugins, extensions and modules · Documentation

Profile
 
 
Posted: 12 November 2008 04:07 PM   [ Ignore ]   [ # 216 ]  
Grad Student
Rank
Total Posts:  67
Joined  10-18-2002

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.

Profile
 
 
   
12 of 14
12
 
Post Marker Legend
New Topic New posts Hot Topic Hot Topic with new posts New Poll New Poll Moved Topic Moved Topic Sticky Topic Sticky topic
Old Topic No new posts Hot Old Topic Hot Topic with no new posts Old Poll Old Poll Closed Topic Closed Topic Announcement Announcements
Theme
Change Theme
Visitor Statistics
The most visitors ever was 1149, on July 16, 2007 09:33 AM
Total Registered Members: 64944 Total Logged-in Users: 67
Total Topics: 81923 Total Anonymous Users: 43
Total Replies: 440352 Total Guests: 293
Total Posts: 522275    
Members ( View Memberlist )