21288 Posts in 5733 Topics by 2602 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 221 Views |
-
compare two csv files in modeladmin interface

6 October 2012 at 10:50am
Hello,
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.
-
Re: compare two csv files in modeladmin interface

9 October 2012 at 7:56pm Last edited: 9 October 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.
http://api.silverstripe.org/3.0/framework/misc/DataDifferencer.html
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 %>
<dt>$Title</dt>
<dd>$Diff</dd>
<% 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.
| 221 Views | ||
|
Page:
1
|
Go to Top |


