One slightly tricky thing is that the categories are the actual names, not the url titles of the categories. For instance, I have a category named “Prospective Members”, and the url title is “prospective-members”. “Prospective Members” is what has to be in the CSV file. So I had to use a non-space delimiter.
As for your index error, that line number is in the file-reading code. If you look at your pi.csvgrab.php, is that line an fseek()? It’s odd and if you’re getting an error there, I’m surprised the import works. If you set trace=”true”, do you get lots of output, including at least one line per imported line?
line 186 is:if ( preg_match( $pat, $item[ $this->publish_date ], $match ) ) {
I can’t find this code anywhere. It is not in the latest version of pi.csvgrab.php from brandnewbox.co.uk, or my patched version. Where did you download CSVgrab from, and how long ago? The first few lines of CSVgrab should look like this (some whitespace removed for clarity):
$plugin_info = array(
'pi_name' => 'CSVGrab',
'pi_version' => '0.2.1',
'pi_author' => 'Andrew Weaver',
'pi_author_url' => 'http://www.brandnewbox.co.uk/docs/',
'pi_description' => 'Allows you to import data from a CVS feed and into a weblog',
'pi_usage' => CSVGrab::usage()
);
Maybe you have an older version?
Oops, yes, I did have an older version. I upgraded to the current version, but now it’s not importing the data at all and when I added trace=”true” to the template, I get this:
TRACE: Array ( [title] => Array ( [is_custom] => 0 [field] => 2 ) [date] => Array ( [is_custom] => 0 [field] => ) [rsrc_program] => Array ( [is_custom] => 1 [field] => 1 [id] => 8 [format] => xhtml ) [rsrc_agency] => Array ( [is_custom] => 1 [field] => 2 [id] => 9 [format] => xhtml ) [rsrc_address] => Array ( [is_custom] => 1 [field] => 3 [id] => 10 [format] => xhtml ) [rsrc_city] => Array ( [is_custom] => 1 [field] => 4 [id] => 11 [format] => xhtml ) [rsrc_zip] => Array ( [is_custom] => 1 [field] => 5 [id] => 12 [format] => xhtml ) [rsrc_phone] => Array ( [is_custom] => 1 [field] => 6 [id] => 13 [format] => xhtml ) [rsrc_phone2] => Array ( [is_custom] => 1 [field] => 7 [id] => 14 [format] => xhtml ) [rsrc_contact] => Array ( [is_custom] => 1 [field] => 8 [id] => 15 [format] => xhtml ) [rsrc_email] => Array ( [is_custom] => 1 [field] => 9 [id] => 16 [format] => xhtml ) [rsrc_url] => Array ( [is_custom] => 1 [field] => 10 [id] => 17 [format] => xhtml ) [rsrc_services] => Array ( [is_custom] => 1 [field] => 12 [id] => 18 [format] => xhtml ) [rsrc_gender] => Array ( [is_custom] => 1 [field] => 13 [id] => 19 [format] => xhtml ) [rsrc_juvenile] => Array ( [is_custom] => 1 [field] => 13 [id] => 20 [format] => xhtml ) [rsrc_adult] => Array ( [is_custom] => 1 [field] => 15 [id] => 21 [format] => xhtml ) [rsrc_seniors] => Array ( [is_custom] => 1 [field] => 16 [id] => 22 [format] => xhtml ) [rsrc_other_eligibility] => Array ( [is_custom] => 1 [field] => 17 [id] => 23 [format] => xhtml ) [rsrc_fees] => Array ( [is_custom] => 1 [field] => 18 [id] => 24 [format] => xhtml ) [rsrc_funding_sources] => Array ( [is_custom] => 1 [field] => 19 [id] => 25 [format] => xhtml ) [rsrc_capacity] => Array ( [is_custom] => 1 [field] => 20 [id] => 26 [format] => xhtml ) [rsrc_grades] => Array ( [is_custom] => 1 [field] => 21 [id] => 27 [format] => xhtml ) [rsrc_st_ratio] => Array ( [is_custom] => 1 [field] => 22 [id] => 28 [format] => xhtml ) [rsrc_hours] => Array ( [is_custom] => 1 [field] => 23 [id] => 29 [format] => xhtml ) [rsrc_certifications] => Array ( [is_custom] => 1 [field] => 24 [id] => 30 [format] => xhtml ) )
TRACE: Resource id #45
OK, that trace indicates the file is being opened successfully, but may not be being parsed successfully. Is the original .csv from a Mac? Did you upload it in text mode (to fix the line endings)?
That error might also occur if the “use” and “fields” value in your template are not in one-to-one correspondence. I looked at your original template several posts back, and it looks OK, but if you have changed it since, doublecheck that.
If you want to PM me with a pointer to some actual data, I could take a look at the file.
I have a problem with CSVGrab.
Following the instructions, everything imported correctly. When I look at the weblog entries using the control panel, everything appears correct.
However, when displaying the imported entries using a very simple template, only my test entry that I entered before the import displays.
Now, if I open and update one of the imported entries, it also displays. However, only the entry title is correct, all the other values display the field name instead of the field contents. Only the test entry displays correctly with the field contents.
Any ideas on what might have gone wrong? Hard to debug since everything appears correct in the control panel.
Thanks,
/Bo
I had a similar problem after using CSVGrab, and this Wiki entry resolved the problem for me.
Go to Admin › Utilities › SQL Manager › Manage Database Tables
Look at exp_categories and exp_category_field_data. They should have the same number of records. If they don’t, that’s probably the cause of your problem and the solution in the Wiki entry should solve it-at least it did for me.
Thanks, Mooo,
You pointed me in the right direction.
My exp_categories and exp_category_field_data have the same number of records so that was not the problem.
However, poking around in the database, I found that all the records had been imported with the wrong site ID. They had the default site ID of 1, instead of 3 as I had specified in my import template. Probably a bug in the plugin. I will dig into the plugin code and see if I can spot it.
Manually fixing the site ID fixes the problem.
Thanks,
/Bo
Two questions!
How do I go about setting a status for imported entries? I have a column in my .csv that lists them as Open, Closed, and Pending - these need to be the associated statusses for the entries. I didn’t see any mention of status in the documentation at all, so if it’s not supported, can I file a feature request for this? 😛
From what I can gather in this thread, having a column for Author is also not supported currently. The 550 entries I need to import are associated with around 60 different authors, and I have a column in the CSV with the ID number of each author. Being able to point the plugin to that column for the author_id would be SO much easier than me having to create 60 different csv files and do the import 60 times, sigh lol! Is that correct? And if so, can I file a feature request for that too?
Andrew, thank you for all your hard work so far, this plugin really is awesome!
I am having trouble getting data to import properly.
The data appears to import properly as I get the feedback that it is going in, but when I check the CP there are no new entries for the designated weblog.
I have confirmed that the desired weblog is 6.
I have attached the upload.csv and import.php files
I would appreciate advice on what I am missing here.
Thanks.
Forrest,
Could you also attach the template output that shows up when you do the import and have trace=”true”? Maybe trim down the data to 5 rows or so there’s not so much to look at.
When you reimport, are you deleting any old data in the weblog that has already been imported with the same or similar values?
If you browse the exp_weblog_data table before and after the import, have any rows been added? Check the column values there to see if it’s going in the wrong place.
Dan,
Thanks for getting back to me on this. I have attached the output file (five rows that is).
Also, the exp_weblog_data table does not reflect any additions for today, nor does it show any entries for weblog id 6.
So the data is going somewhere, but I suspect it may be ending up on the floor in the server closet.
Your thoughts?
Thanks.
Forrest and I took this off-line. The problem is that the unique checker in CSVgrab does not try to match the weblog_id when checking the specified field for uniqueness. Forrest has a custom field shared among more than one weblog, and had existing entries in another weblog that satisfied the uniqueness test.
I patched CSVgrab quickly for him to match the weblog_id as well. This is an unusual situation that probably doesn’t affect most people. Andrew, this is something to note for your next version.
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.