2 of 14
2
Plugin: CSVGrab
Posted: 22 January 2007 03:17 PM   [ Ignore ]   [ # 19 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  878
Joined  05-14-2004

Cheers Andrew. I think its safe to assume its not your plugin thats caused the problem. its something else. I think its something outside of EE which is annoying cos i dont use much outside of EE! Hopefully when i get this issue squared away and get CSVgrab working. your plugin looks like it could save me many many hours of work.

Profile
 
 
Posted: 28 January 2007 10:17 AM   [ Ignore ]   [ # 20 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  878
Joined  05-14-2004

Hey Andrew. I’m back. And things are still not working.

After trying some new data and getting nothing but a spinning loading icon in Firefox and empty entries in EE I’m back begging for help.

If i understand everything correctly this should be very simple but I can’t get it to work.

My csv file looks like this

File Name    Capture Date    Category    Location    Creator
djw_20061117_28649
.jpg    17/11/2006 19:16:10    Bird Lane    Cafe de Paris    David Webb
djw_20061117_28718
.jpg    17/11/2006 20:03:17    Belgrave Scandal    Cafe de Paris    David Webb
djw_20061117_28760
.jpg    17/11/2006 20:39:32    Scouting for Girls    Cafe de Paris    David Webb
djw_20061117_28836
.jpg    17/11/2006 21:22:32    Educated Animals, The    Cafe de Paris    David Webb

In the future I want to add 3 more fields but for now I just want this in my db

File Name maps to the “title” field
Category maps to the “v2_img_band” field and
Location maps to the “v2_img_venue” field.

I’d like “Capture Date” to map to the “entry date” and “Creator” map to the “Author”. I can’t see how to do that (I’m hoping its possible but figured it wouldn’t hurt to have the info in the CSV and ignore it at the moment.)

Now my template has this in it

{exp:csvgrab url="http://acuityimages.com/20061177_me.csv"
    
weblog="16"
    
title="1"
    
skip="1"
    
delimiter="TAB"
    
encloser=""
    
use="3|4"
    
fields="v2_img_band|v2_img_venue" }

I can add ” ” to the CSV if its recommended but I’m trying to keep things simple.

As I’m finishing writing this the template it still loading and I have one empty entry in my “images” weblog.

I can give you a login to my site if you think it’d help you troublehsoot but at the moment I’m at a loss as to what to do or try.

Thanks in advance for any and all help you can offer.

Profile
 
 
Posted: 28 January 2007 02:37 PM   [ Ignore ]   [ # 21 ]  
Lab Assistant
RankRank
Total Posts:  165
Joined  12-21-2005
DavidJaymz - 28 January 2007 10:17 AM

I can give you a login to my site if you think it’d help you troublehsoot

That might be helpful. For now, can you send me a copy (or link) to your CSV file. The one you have in your plugin was giving me a 404 error.

 Signature 

Andrew Weaver — brandnewbox.co.uk


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

Profile
 
 
Posted: 28 January 2007 03:41 PM   [ Ignore ]   [ # 22 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  878
Joined  05-14-2004

Cheers Andrew Just sent you a pm.

The correct url to the csv is http://acuityimages.com/20061117_me.csv I typed it wrong in the forum.

Profile
 
 
Posted: 05 February 2007 10:18 AM   [ Ignore ]   [ # 23 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  774
Joined  07-18-2006

Hi Andrew,

I was just about to start writing a plug-in/module along these lines and then stumbled upon yours.  I have quite a bit of additional functionality that is pretty specific to the project I’m working on though. I wonder how you would feel if I used this as a jumping off point for my own module for this project?

Basically we’re going to be using an uploaded CSV file to keep a database of member companies up to date on the website.  In doing so there are a few things that need to happen:

• On an upload, if the company is new the system needs to generate a random password for that company and enter that into the appropriate field. That password needs to be emailed to an address that is provided in the CSV itself (the main company contact).
• If the company is already in the system it needs to check and see if anything has changed - if it has then update those fields.
• If the company is currently in the system but isn’t in the CSV it needs to delete that company from the database.
• After upload we’re going to count the number of current member companies and generate an image based on that number (for the home page).

To start I’ll probably just have a page where someone can upload the file and everything happens automatically. Depending on how much time I have I should probably make an area in the CP where this happens and gives important feedback before the CSV is accepted.  Which companies are being added, which are being removed, etc.

Any thoughts about the things above? Would you be ok if I use your plug-in as a jump-start on my own? Obviously any work I do I would give back to you if you’d like to use it…

Thanks Andrew.

Profile
 
 
Posted: 05 February 2007 02:14 PM   [ Ignore ]   [ # 24 ]  
Lab Assistant
RankRank
Total Posts:  165
Joined  12-21-2005
The Pie Man - 05 February 2007 10:18 AM

I wonder how you would feel if I used this as a jumping off point for my own module for this project?

Please feel free to use this plugin as a jumping off point. Some of the code is a bit messy at the moment - a tidy-up is on my to do list. Also, on the to do list is the ability to do updates but you’ll probably get that working before I get a chance to…

Let me know if I can be any help

 Signature 

Andrew Weaver — brandnewbox.co.uk


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

Profile
 
 
Posted: 05 February 2007 02:30 PM   [ Ignore ]   [ # 25 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  774
Joined  07-18-2006

Thanks Andrew smile

I’ll keep you posted - I’ll probably be working on this either next week or the week after. Just wanting to get all my ducks in a row.

Profile
 
 
Posted: 08 February 2007 07:38 AM   [ Ignore ]   [ # 26 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  774
Joined  07-18-2006

Andrew - I ended up starting from scratch.  I looked through your plug-in and I decided it would be just as easy as we’re coming at things from a slightly different angle - also it’s my first module so I thought I’d go through the tutorial and learn things from the ground up.  I’ve got it up and running now - I’ve got a couple questions I’m going to post in the module tech support forum if you’re interested in looking at the module smile

Profile
 
 
Posted: 02 March 2007 05:42 PM   [ Ignore ]   [ # 27 ]  
Grad Student
Rank
Total Posts:  56
Joined  11-25-2005

Just so I am clear what this plugin does… it technically only links to the .csv file and diplays it in a template. It doesn’t physically import it into the database.

Let me know if I am wrong.

I have a .csv file I want to permanetly import into a new weblog with custom fields. I am hoping this will do the trick.

Profile
 
 
Posted: 03 March 2007 08:12 AM   [ Ignore ]   [ # 28 ]  
Lab Assistant
RankRank
Total Posts:  165
Joined  12-21-2005

The CSVGrab will import data into a weblog as you require.

 Signature 

Andrew Weaver — brandnewbox.co.uk


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

Profile
 
 
Posted: 05 March 2007 10:01 AM   [ Ignore ]   [ # 29 ]  
Grad Student
Rank
Total Posts:  56
Joined  11-25-2005

Is there a detailed how to page I can referrence for this plugin. I am confused about the template code people are discussing and how I can import the data from one of my csv files into a new weblog.

Sorry for this newbee question.

Profile
 
 
Posted: 18 April 2007 03:40 AM   [ Ignore ]   [ # 30 ]  
Lab Assistant
RankRank
Total Posts:  127
Joined  01-12-2006

I’ve got to import several thousand entries into EE and thought I’d give CSVGrab a try. Initially I broke the data into 1000 line chunks and have gone right the way down to a single line of data. Despite that I’m having the very same problem as David and the page loads for a good few minutes before timing out. I’ve tried adding some debugging messages to the plugin and flushing the output buffer but it appears to have no affect within plugins (or perhaps that’s a symptom of whatever the problem is).

If anyone had this problem and found a solution I’d love to hear it.

Thanks,
Dom

 Signature 

VayaDesign | EE Design & Development Services
EE Goodies: TealTemplate, Simple Pagination Plugin

Profile
 
 
Posted: 18 April 2007 03:49 AM   [ Ignore ]   [ # 31 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  878
Joined  05-14-2004

Hey Dom.

My problem was in how the external file was being referenced. My host didn’t allow php to load the file in the way csvgrab asks for it. I just replaced the http file call with a server path call and it all worked.

{exp:csvgrab url="/home/directory/directory/bands.csv"

Hope this helps.

Profile
 
 
Posted: 18 April 2007 03:52 AM   [ Ignore ]   [ # 32 ]  
Lab Assistant
RankRank
Total Posts:  165
Joined  12-21-2005

Hi Dom,

Thanks for the post. It is always appreciated when people tell me of a problem (even if my first reaction is less positive).

Out of interest, from your debugging could you tell whether the CSV was getting loaded? I think some web hosts have tighter PHP security than others, which prevent the file loading.

Andrew

 Signature 

Andrew Weaver — brandnewbox.co.uk


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

Profile
 
 
Posted: 18 April 2007 03:54 AM   [ Ignore ]   [ # 33 ]  
Lab Assistant
RankRank
Total Posts:  165
Joined  12-21-2005

Thanks David. Dom - could you try David’s suggestion when you get a chance and let me know if it helps.

I’ll look into improving the code to get remote files.

 Signature 

Andrew Weaver — brandnewbox.co.uk


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

Profile
 
 
Posted: 18 April 2007 05:02 AM   [ Ignore ]   [ # 34 ]  
Lab Assistant
RankRank
Total Posts:  127
Joined  01-12-2006

Thanks for the quick responses guys. Unfortunately I think in an all-time first I really wish you hadn’t, as as soon as I submitted the post I scanned through my code again and realised that a closing bracket was missing from the plugin tag. I could’ve sworn that I put one in there after the 50 item field list but apparently not! Anyway, no chance to delete my post so I’ll have to admit to it. raspberry

I’m now in the process of importing nearly 22,000 entries, each with around 50 fields. So far the plugin has been faultless and I can’t thank you enough Andrew for providing such a time saving tool. One change I have had to make which may be useful to others, is that the duplicate title checking was a problem for me as I’m importing a huge list of businesses, some of which do have the same name. As a result the standard behaviour of the plugin was ignoring 6 out of the 7 businesses named ‘7 Eleven’ for instance.

To disable this just change the following on around line 148:

if ($query->num_rows == 0) {

To:

if ($query->num_rows == 0 or $query->num_rows > 0) {

(Yes you could also remove the if statement entirely, but this is a little easier than digging around for the closing bracket as well, and we all know what trouble I have with them.)

Also if anyone else has so much data they need to split it across several files, here’s a semi-batch import solution which may be of use:

<?php
    
print "<h1>IMPORTING DATA</h1>";
    
ob_flush();
    
flush();
    
$nextpage = "{segment_3}" + 1;
?>

{exp
:csvgrab
    url
="http://yoursite.com/data/{segment_3}.txt"
    
otherparams
}

<br /><br /><a href="{path=import_debug/csvgrab/<?=$nextpage;?>}">Next File</a>

Finally, again if you need to split a large file, I used GSplit which is free and lets to specify exactly how many lines you want per file.

Hopefully that’s all of use to others if they need to do something similar in the future.

P.S. Small world, David. I’m in Portsmouth and have been to a fair chunk of the venues on your photos site. Nice site it is too btw!

 Signature 

VayaDesign | EE Design & Development Services
EE Goodies: TealTemplate, Simple Pagination Plugin

Profile
 
 
Posted: 18 April 2007 06:33 AM   [ Ignore ]   [ # 35 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  878
Joined  05-14-2004

Glad you got your problem sorted Dom, and thanks for the kind words. If you ever see me at a gig come say hi.

Profile
 
 
Posted: 18 April 2007 06:40 AM   [ Ignore ]   [ # 36 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  774
Joined  07-18-2006

If you’ve changed it so it will accept entries with the same title - are you going to have entries with the same url_title?  That seems like that could be a real problem. Thought I’d mention that although you’ve probably thought of it already…

Profile
 
 
   
2 of 14
2
 
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: 64553 Total Logged-in Users: 31
Total Topics: 81156 Total Anonymous Users: 25
Total Replies: 436592 Total Guests: 193
Total Posts: 517748    
Members ( View Memberlist )