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

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

Can you include some more of what the template showed in its debugging output? How about the TRACE’s? Were there any lines that said ‘Checking” or “Found new entry: …”? Maybe try a shorter version of the data (only a few rows) and include the complete output.

       
jejuna's avatar
jejuna
105 posts
16 years ago
jejuna's avatar jejuna

Dan, your answer about using CSVGrab to update existing entries, above:

>> CSVGrab will write over an existing entry if the “unique” field you specify matches the same field in the existing entry. In your case, this is “official-name”. So you can reimport multiple times. <<

I don’t think this is correct. The documentation states the opposite, actually:

“The unique field determines which fields are checked to see if the current feed element has already been imported e.g.: unique=”title,date” will not import any items with the same title and date as an existing element in the selected weblog. Note, the field names are the fields set up within your own weblog (ie, title, date, and any custom fields) not the names of the fields in the feed.”

I’ve tried this, and it works like the documentation says. So, if you modify your CSV file, and re-import, you’ll get duplicates, or nothing, depending on what’s set as “unique”.

If Andrew (or someone) would modify the plugin or make a similar one called something like “CSVUpdate” so it COULD be used for updates, I would be jumping for joy.

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

Debra, thanks for pointing this out. I have edited my previous entry. Sorry - I was importing the same data file over and over and failed to notice it was just skipping those entries.

       
Richard Frank's avatar
Richard Frank
200 posts
16 years ago
Richard Frank's avatar Richard Frank

Hi

I’m having trouble importing entries. It looks like the plugin needs an encloser. Excel does not save CSV’s with enclosers, so I’m a bit stuck!

Richard

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

Try adding an encloser=”QUOTE” or encloser=”’”. The parameter is now required by the PHP function the plugin uses, but I think it will ignore it if the file does not need it. (I think…)

Andrew

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

I just ran a little test with the PHP function fgetcsv(), which is what CSVGrab uses. I tried two .csv files, one with quotes, and one without, and set the enclosure to ‘”’. It did parse and read both files correctly, so Andrew’s surmise is correct. (At least for PHP 5.2.6, which is what I’m using.)

Interestingly, if I set the enclosure to ” (empty string), I get PHP warnings: “enclosure must be a character”

       
Richard Frank's avatar
Richard Frank
200 posts
16 years ago
Richard Frank's avatar Richard Frank

Thanks for the responses. I am having some success using encloser=”QUOTE”, but not with nothing in it.

Andrew, was that a typo above, or did you really mean:

encloser=”‘“
       
scottb's avatar
scottb
343 posts
16 years ago
scottb's avatar scottb

We need to build a product that allows members to upload csv files into a weblog. They will be uploading more than 150 files weekly.

Can csvgrab be used with cron so we don’t have to take the manual step of going to the page to call the function? I asked a similar question on the FeedGrab board to use with a different product. I tried the EE cron plugin on FeedGrab, but so far I haven’t been able to make it work.

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

Yes, I use cron to call the plugin. Set up the template as you would normally, and then get the cronjob to access the web page using something like wget or lynx, eg,

wget http://yoursite.com/index.php/your-template-group/your-import-timeplate

       
scottb's avatar
scottb
343 posts
16 years ago
scottb's avatar scottb

Thanks, Andrew. And thanks for those plugins. I think we will be able to use them for some interesting projects.

       
adamb's avatar
adamb
8 posts
16 years ago
adamb's avatar adamb

Quick question, Does the revised plugin support the auto increment feature when it detects a duplicate title being imported.

Basically i’m trying to import 3673 entries, but due to some of them having the same title, it is importing 1763.

Is there a way for the current version of the plugin to import the same title, but modify the url_title.

I noticed there is now a ‘unique’ parameter option, but I do not think it applies to this case… I could be mistaken..

any thoughts?

— andrew thanks so much for developing this plugin, and your continued work into it..—

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

The unique parameter does tell the plugin what to look at to determine if an entry is a duplicate.

It defaults to using the title and date, so try setting it to a custom field that will always be different.

       
adamb's avatar
adamb
8 posts
16 years ago
adamb's avatar adamb

worked great andrew! thanks again…

       
webrsm's avatar
webrsm
47 posts
16 years ago
webrsm's avatar webrsm

Hi

Im not sure if this is the right place to post this sorry if its not, i followed the tutorial on how to set up the CSVGrab, but when i have gone to test I get the following error (swapped site name for mysite)

Warning: fopen(mysite/DFS.csv) [function.fopen]: failed to open stream: Connection refused in /home/sites/mysite/public_html/office/plugins/pi.csvgrab.php on line 192

Warning: fgetcsv(): supplied argument is not a valid stream resource in mysite/public_html/office/plugins/pi.csvgrab.php on line 202

Warning: fclose(): supplied argument is not a valid stream resource in mysite/public_html/office/plugins/pi.csvgrab.php on line 478

am i missing something??

L

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

It looks like the plugin is not finding the CSV file.

Try using a URL (eg, http://msysite.com/mycsvfile.csv) or an absolute path (eg, /home/youracct/mycsvfile.csv)

       
First 9 10 11 12 13 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.