Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

compare two csv files in modeladmin interface

Go to End

2 Posts   763 Views


Community Member, 82 Posts

6 October 2012 at 10:50am


I know SS has the ability to import csv files and show results. In my case I want to compare two csv files and show the records that match. I assume this would need two upload fields and converting the csv data to arrays which need to be compared. If this is the best way, can someone give an example how to do that on silverstripe?

thanks in advance.


Forum Moderator, 5523 Posts

9 October 2012 at 7:56pm

Edited: 09/10/2012 7:57pm

SilverStripe also has a Diff library bundled (framework/core/Diff.php) which is used for showing diffs between page versions (DataDifferencer), haven't used it too much so I personally can't help much but take a look to see if those classes can help.

The usage of that is something like

function getDifferences() {
$obj1 = DataObject::get_one('Member');
$obj2 = DataObject::get_one('Member');

return new DataDifferencer($obj1, $obj2);

// then in the template
<% with Differences %>
<% loop ChangedFields %>
<% end_loop %>
<% end_with %>

How you get that displayed to the user depends on your use case. You could embed the template as a FormField within model admin or a separate controller would work.