-
-
Notifications
You must be signed in to change notification settings - Fork 202
Description
Expected Behavior
Should mark the differences between the two lists or two files. In my example, I have information stored in CSV files.
Actual Behavior
At first appears to correctly identify the differences between two CSV files, but later the differences are incorrectly marked. I've also tried this with two lists that have the same structure.
The last three lines show it skipping some differences and marking others incorrectly, like putting ** in front rather than around the item that is not the same ('**TASK'), and not marking the differences at all on the last line on the second file but marking them on the first ('ACTIONS_C16913').
Steps to Reproduce the Problem
- Have two lists or two files containing a structure similar to this:
File One
(snip)
TABLE_NAME, COLUMN_NAME, DATA_TYPE, DATA_LENGTH, DATA_PRECISION, NULLABLE,
ACTIONS_C17005, ID, NUMBER, 22, 19, N,
ACTIONS_C17005, ISSUEID, NUMBER, 22, 19, Y,
ACTIONS_C17005, MODIFIED, NUMBER, 22, 10, Y,
ACTIONS_C17005, TABLE, VARCHAR2, 1020, null, Y,
ACTIONS_C17005, S_NAME, CLOB, 4000, null, Y,
ACTIONS_C17008, ID, NUMBER, 22, 19, N,
ACTIONS_C17008, ISSUEID, NUMBER, 22, 19, Y,
ACTIONS_C17008, MODIFIED, NUMBER, 22, 10, Y,
File Two
(snip)
TABLE_NAME, COLUMN_NAME, DATA_TYPE, DATA_LENGTH, DATA_PRECISION, NULLABLE,
ACTIONS_C16913, ID, NUMBER, 22, 19, N,
ACTIONS_C16913, ISSUEID, NUMBER, 22, 19, Y,
ACTIONS_C16913, MODIFIED, NUMBER, 22, 10, Y,
ACTIONS_C16913, VRS, NUMBER, 22, 1, Y,
ACTIONS_C16913, ZTABS, VARCHAR2, 255, null, Y,
ACTIONS_C16913, ZTABS_S, VARCHAR2, 255, null, Y,
ACTIONS_C16913, TASK, VARCHAR2, 255, null, Y,
ACTIONS_C16913, HOURS_SPENT, VARCHAR2, 255, null, Y,
import com.github.difflib.algorithm.DiffException;
import com.github.difflib.text.DiffRow;
import com.github.difflib.text.DiffRowGenerator;
import java.io.*;
import java.util.ArrayList;
import java.util.List;
public class Demo {
public static void main(String[] args) throws DiffException, IOException {
final String FIRSTDB = "C:\\dev\\fileOneSchema.csv";
final String SECONDDB = "C:\\dev\\fileTwoSchema.csv";
BufferedReader in = new BufferedReader(new FileReader(FIRSTDB));
String strOne;
List<String> listOne = new ArrayList<String>();
while ((strOne = in.readLine()) != null) {
listOne.add(strOne);
}
BufferedReader inTwo = new BufferedReader(new FileReader(SECONDDB));
String strTwo;
List<String> listTwo = new ArrayList<String>();
while ((strTwo = inTwo.readLine()) != null) {
listTwo.add(strTwo);
}
DiffRowGenerator generator = DiffRowGenerator.create()
.showInlineDiffs(true) //show the ~ ~ and ** ** symbols on each difference
.inlineDiffByWord(true) //show the ~ ~ and ** ** around each different word instead of each letter
//.reportLinesUnchanged(true) //experiment
.oldTag(f -> "~")
.newTag(f -> "**")
.build();
List<DiffRow> rows = generator.generateDiffRows(listOne, listTwo);
for (DiffRow row : rows) {
System.out.println("|" + row.getOldLine() + "| " + row.getNewLine() + " |");
}
}
}
- Result
|TABLE_NAME, COLUMN_NAME, DATA_TYPE, DATA_LENGTH, DATA_PRECISION, NULLABLE,| TABLE_NAME, COLUMN_NAME, DATA_TYPE, DATA_LENGTH, DATA_PRECISION, NULLABLE, |
|ACTIONS_C17005, ID, NUMBER, 22, 19, N, | ACTIONS_C16913, ID, NUMBER, 22, 19, N, |
|ACTIONS_C17005, ISSUEID, NUMBER, 22, 19, Y, | ACTIONS_C16913, ISSUEID, NUMBER, 22, 19, Y, |
|ACTIONS_C17005, MODIFIED, NUMBER, 22, 10, Y, | ACTIONS_C16913, MODIFIED, NUMBER, 22, 10, Y, |
|ACTIONS_C17005,TABLE, VARCHAR2,1020, null, Y, | ACTIONS_C16913, VRS, **NUMBER, 22, 1, Y, |
|ACTIONS_C17005,S_NAME,CLOB,4000, null, Y, | ACTIONS_C16913, ZTABS, **VARCHAR2, 255, null, Y, |
|ACTIONS_C17008, ID, NUMBER, 22, 19, N, | ACTIONS_C16913, ZTABS_S, VARCHAR2, 255, null, Y, |
|ACTIONS_C17008, ISSUEID, NUMBER, 22, 19, Y, | ACTIONS_C16913, **TASK, VARCHAR2, 255, null, Y, |
|ACTIONS_C17008, MODIFIED, NUMBER, 22, 10, Y, | ACTIONS_C16913, HOURS_SPENT, VARCHAR2, 255, null, Y, |
Specifications
- Version: com.github.wumpz:diffutils:2.2
- Platform: Windows 7, JDK 8, IntelliJ 2017.3.4
- Subsystem: