Question: Will the plugin allow for “updating” an original imported list? Or, do entries have to be deleted and re-imported to update information? (if, for example, we had multiple changes to multiple entries)
CSVGrab will write over an existing entry [WRONG: see reply #151] 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.
You may find it helpful to set trace="TRUE” (actually trace=anything). This makes CSVgrab print out some info about what it is doing during the import.
TRACE: 1 - Array ( [0] => John Doe [1] => Doe ...)
The “Resource id” trace is a handle to the input file, and the second trace shows you the contents of the csv line it just read.
So it looks like it is not reading your CSV file at all. Test the URL to make sure it’s right, and assuming it works, you can instead try pointing to a local file instead of using a URL. The path is relative to the your top-level web directory (e.g. public_html/ or www/), or, use an absolute path (/home/youraccount/public_html/foo.csv) or whatever is appropriate for your webhosting account.
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.
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.
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.
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...)
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”
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.
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,