1 of 14
1
Plugin: CSVGrab
Posted: 18 December 2006 10:12 AM   [ Ignore ]  
Lab Assistant
RankRank
Total Posts:  165
Joined  12-21-2005

CSVGrab is a variation of one of my other plugins FeedGrab, and allows you to import data from a CSV file into a weblog.

Usage is similar to FeedGrab, the template:

{exp:csvgrab url="http://www.url.co.uk/products.csv"
                          
weblog="5"
                          
title="1"
                          
skip="6"
                          
delimiter="TAB"
                          
encloser=""
                          
use="2|3"
                          
fields="prod_description|prod_keywords" }

imports a tab delimited CSV file into the weblog with id of 5, skipping the first 6 lines.

It uses column 1 as the title field, and columns 2 and 3 as the custom fields prod_description and prod_keywords.

delimiter is the character that separates the columns, encloser is the character that wraps the column.

eg, “Title”,“Description”,“Keywords” has a comma delimiter and a quote encloser.

The plugin was developed for a particular client’s requirements - let me know if there are any future development requests.


Edit: Please see the CSVGrab page to download current version

 Signature 

Andrew Weaver — brandnewbox.co.uk


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

Profile
 
 
Posted: 18 December 2006 10:24 AM   [ Ignore ]   [ # 1 ]  
Lab Assistant
RankRank
Total Posts:  165
Joined  12-21-2005

Further note:

EE ‘cleans up’ plugin parameters, so for delimiter and encloser use the following codes rather than the actual character: TAB, SPACE, QUOTE

eg,

delimiter="TAB" encloser="QUOTE"

 Signature 

Andrew Weaver — brandnewbox.co.uk


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

Profile
 
 
Posted: 18 December 2006 02:01 PM   [ Ignore ]   [ # 2 ]  
Moderator
Avatar
RankRankRankRankRankRankRankRank
Total Posts:  32861
Joined  05-14-2004

I’ve added this here - I hope you’ll keep that updated if you get this added to the plugins site, etc.  Great tool, thank you. =)

 Signature 
Profile
MSG
 
 
Posted: 03 January 2007 01:01 PM   [ Ignore ]   [ # 3 ]  
Lab Assistant
RankRank
Total Posts:  201
Joined  12-31-2002

“EE ‘cleans up’ plugin parameters, so for delimiter and encloser use the following codes rather than the actual character: TAB, SPACE, QUOTE “

I know this will sound silly, but do we use “COMMA” for the comma?  That’s not a standard expression to my limited knowledge.

Profile
 
 
Posted: 03 January 2007 02:48 PM   [ Ignore ]   [ # 4 ]  
Lab Assistant
RankRank
Total Posts:  165
Joined  12-21-2005

You should be able to just use a normal comma - the problem is mainly with ‘whitespace’ characters.

 Signature 

Andrew Weaver — brandnewbox.co.uk


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

Profile
 
 
Posted: 06 January 2007 06:36 AM   [ Ignore ]   [ # 5 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  879
Joined  05-14-2004

Hey Andrew, This plugin looks like it could be very useful to me on a couple of sites. Is there a way to specify categories for the “entries” to go into?

Profile
 
 
Posted: 06 January 2007 09:44 AM   [ Ignore ]   [ # 6 ]  
Lab Assistant
RankRank
Total Posts:  201
Joined  12-31-2002

I just imported a test run of posts into one of my categories.  If you look at the plug-in code, you’ll find several variables that aren’t documented yet.  One of them is “cats”.  I don’t know how it works just yet, but my test was successful in defining it like this:

exp:csvgrab url="http://www.mydomainname.com/products.csv"
                          
weblog="7"
                          
cats="Social Studies Curriculum"
                          
title="1"
                          
skip="1"
                          
delimiter=","
                          
encloser="QUOTE"
                          
use="2|3|4"
                          
fields="summary|body|metakeywords }

Metakeywords is a custom field we use to include in our headers.

I don’t know if you can put more than one category in (the variable name suggests you can).

BTW:  If you have non-printable characters in your CSV your posts will have ugly ASCII characters in some places.  I was able to fix these in Xcel with the “CLEAN()” function.

Hope that helps.

Profile
 
 
Posted: 06 January 2007 09:55 AM   [ Ignore ]   [ # 7 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  879
Joined  05-14-2004

Hey Tony, Just looked in the file itself and your right. It does look like we can specify a category for the entries to go into. grin I wonder if there’s a way to get the category from the CSV rather than specifying it. hmmm.

Profile
 
 
Posted: 06 January 2007 11:14 AM   [ Ignore ]   [ # 8 ]  
Lab Assistant
RankRank
Total Posts:  201
Joined  12-31-2002

You’d probably have to modify the plug-in unless there’s a parameter for that…. Andrew?

Profile
 
 
Posted: 06 January 2007 05:00 PM   [ Ignore ]   [ # 9 ]  
Lab Assistant
RankRank
Total Posts:  165
Joined  12-21-2005

This is all rather untested, so use at your own peril…

The category parameter puts all entries into a specified category.

You can use the category name or id, eg:

category="Arts"

or

category="1"

Alternatively, you can get the category from the CSV file, using the category_field and category_group parameters.

category_field selects which column to use, and new categories are created if they do not exist. It currently does not do anything clever to separate multiple categories.

The category_group parameter is the id of the category group into which the new categories should be added (can be found on the Admin › Weblog Administration › Category Groups page in the Control Panel).

eg,

category_field="4"
category_group="3"

I should reiterate: this has not been tested very stringently - it was added for a client who eventually did not need it - which is why I had not documented it yet.

Let me know how you get on - I will try to fix any bugs and I’m open to feature requests.

Good luck!

 Signature 

Andrew Weaver — brandnewbox.co.uk


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

Profile
 
 
Posted: 07 January 2007 08:49 AM   [ Ignore ]   [ # 10 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  879
Joined  05-14-2004

Cheers Andrew. I’ll test it out as soon as I’ve finalised my structure.

Profile
 
 
Posted: 08 January 2007 07:46 AM   [ Ignore ]   [ # 11 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  879
Joined  05-14-2004

Hi Andrew me again.

If I’m reading your php correctly it looks like you’ve hard-coded the author id. Would it be possible to have this as a field to be pulled from the csv either by id or display name (pref display name)?

I’d also like to be able to set the entry date (& time if we can) from the csv. It looks like your using current time at the moment.

Thanks again and I hope you don’t mind me asking.

Profile
 
 
Posted: 10 January 2007 03:35 PM   [ Ignore ]   [ # 12 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  879
Joined  05-14-2004

OK I’m not getting this to work…

I figured I’d try my simple import first.

“Bands Name”,“Bands URL”

So here’s my CSVGrab tag

{exp:csvgrab url="http://acuityimages.com/v2_bands.csv"
    
weblog="18"
    
title="1"
    
skip="6"
    
delimiter=","
    
encloser="QUOTE"
    
use="2"
    
fields="v2_bandvenues_url" }

Here’s a couple of lines of my csv (and the rest is attached)

"1990's","http://www.myspace.com/1990sband"
"22/20s"
,"http://www.myspace.com/2220s"
"65daysofstatic"
,"http://www.65daysofstatic.com/"
"69 Eyes"
,"http://www.69eyes.com/"
"747s"
,"http://www.747s.co.uk/"

I upload the csv go to my csvgrab template and it starts to load. after maybe 30-40s a blank entry appears after that nothing it just keeps spinning and adding no more entries. real or empty like the first one.

Have I missed something?

File Attachments
v2_bands.txt  (File Size: 32KB - Downloads: 2662)
Profile
 
 
Posted: 13 January 2007 04:44 AM   [ Ignore ]   [ # 13 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  879
Joined  05-14-2004

Well I’ve continued to try and get this to work but I’m failing miserably.

I’ve changed the CSVGrab tag to

{exp:csvgrab url="http://acuityimages.com/test.csv" weblog="18" title="1" delimiter="TAB" use="2" fields="v2_bandvenues_url" }

and my csv file is now

65daysofstatic    http://www.65daysofstatic.com/
69 Eyes    http://www.69eyes.com/
747s    http://www.747s.co.uk/

I figured I’d go simple and just TAB separate the data and try it with a smaller amount of data…

But I still get nothing. Occasionally CSVGrab will insert a blank entry but 9/10 times the loading icon just spins in firefox and NOTHING happens.

I thought it might be getting hung up on the special characters in some bands names (’ - etc) so i took those out but still no dice.

Can anyone clarify that they’ve got CSVGrab working and tell me if my data is wrong?

Thanks in advance.

DJ

Profile
 
 
Posted: 19 January 2007 03:25 AM   [ Ignore ]   [ # 14 ]  
Lab Assistant
RankRank
Total Posts:  165
Joined  12-21-2005

Hi David,

Sorry for not replying sooner - for some reason I’ve only just seen your last couple of posts.

I’ve just tested the code in your last post:

{exp:csvgrab url="http://acuityimages.com/test.csv" weblog="18" title="1" delimiter="TAB" use="2" fields="v2_bandvenues_url" }

and it works fine for me (when I change were the weblog and fields to parameters to appropriate ones for my setup).

Are you still having problems?

 Signature 

Andrew Weaver — brandnewbox.co.uk


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

Profile
 
 
Posted: 19 January 2007 01:51 PM   [ Ignore ]   [ # 15 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  879
Joined  05-14-2004

Yup. Still having issues. Any suggestions on a good way to troubleshoot this? I’m stuck. even more so if my data worked for you.

Profile
 
 
Posted: 22 January 2007 04:42 AM   [ Ignore ]   [ # 16 ]  
Lab Assistant
RankRank
Total Posts:  165
Joined  12-21-2005

I could add some extra debugging information to the plugin and email it you. This might give us a bit more to go on.

9/10 times the loading icon just spins in firefox and NOTHING happens

This suggests to me that something more serious is going wrong. Loading a 3 line CSV file and dumping the data into the database should be quick - it runs in no time on my install of EE and I’ve had reports on several thousand line imports happening in seconds.

 Signature 

Andrew Weaver — brandnewbox.co.uk


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

Profile
 
 
Posted: 22 January 2007 02:31 PM   [ Ignore ]   [ # 17 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  879
Joined  05-14-2004

Hey andrew apologies for the delay in getting back to you. you may have seen my other thread where my sites are now fubar’d because of a process eating far too much php memory.

Is there a way to check CSVGrab is no longer running? At the moment I’m turning off as much as i can and moving things around to try and find the culprit. not sure what it could be. not that up on php memory usage.

Profile
 
 
Posted: 22 January 2007 03:11 PM   [ Ignore ]   [ # 18 ]  
Lab Assistant
RankRank
Total Posts:  165
Joined  12-21-2005

Hi David

I had noticed the other thread - hope you manager to sort it out soon.

DavidJaymz - 22 January 2007 02:31 PM

not that up on php memory usage.

Me neither, sorry, but I’ll try and help.

The CSVGrab plugin - as it is called from a template - will only run when that page is loaded and will only run for the duration of time it takes that page to load. Once a page has loaded, or has been timed-out by the web server, the plugin will stop running (the plugin does not do anything to extend the page load timeout)

If that page is not getting loaded then the CSVGrab plugin should not be running in the background anymore.

 Signature 

Andrew Weaver — brandnewbox.co.uk


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

Profile
 
 
   
1 of 14
1
 
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: 64914 Total Logged-in Users: 16
Total Topics: 81866 Total Anonymous Users: 14
Total Replies: 440122 Total Guests: 160
Total Posts: 521988    
Members ( View Memberlist )
Newest Members:  smilepolitelyrvmcleodbjmohrAqua193Bios Elementmjpoteetguimogranwelshmrcfthenetmonkey
Active Members:    3000CarloCMICrucialgreyfodderiainjo22JohnDkarentemplerLisa WessLLeakemjdsoli-studioRobb OttenhoffrvmcleodSusan