Usecase Beispiele ======================================================================================================================== In diesem Kapitel werden Beispiele für verschiedene Szenarien angeführt. Es wird davon ausgegangen das ausführliche Kenntnisse in Konfiguration und Anwendung von NCDiff vorliegen. CSV Format ------------------------------------------------------------------------------------------------------------------------ .. code-block:: cfg [DEFAULT] oldFormat=CSV newFormat=CSV bothNumberFormat=DE bothCSVDelimiter=; [GLOBAL] resultFormats=HTML oldDirectory=data/old/ newDirectory=data/new/ resultDirectory=results/ [example001_csv] oldFilePath=example001.old.csv newFilePath=example001.new.csv oldKeyColumns=1 newKeyColumns=1 keepTempFiles=True XLS Format ------------------------------------------------------------------------------------------------------------------------ .. code-block:: cfg [DEFAULT] oldFormat=XLS newFormat=XLS bothNumberFormat=DE [GLOBAL] resultFormats=HTML,CSV,XLS oldDirectory=data/old/ newDirectory=data/new/ resultDirectory=results/ [example002_csv] bothXLSSheetName=data 123 oldFilePath=example002.old.xls newFilePath=example002.new.xls bothKeyColumns=1 keepTempFiles=True   FixedWidth Format ------------------------------------------------------------------------------------------------------------------------ .. code-block:: cfg [DEFAULT] oldFormat=XLS newFormat=XLS oldNumberFormat=DE newNumberFormat=DE [GLOBAL] resultFormats=HTML oldDirectory=data/old/ newDirectory=data/new/ resultDirectory=results/ [example003_fixedwidth] oldFilePath=example003.old.txt newFilePath=example003.new.txt bothKeyColumns=1 oldFormat=FixedWidth newFormat=FixedWidth bothColumnWidths=2,4,7,10,11,11,4 keepTempFiles=True XML Format ------------------------------------------------------------------------------------------------------------------------ Vergleich von zwei XML Dateien mit komplett ignorieren der Spalte „fx“ in der „new“ Datei und allgemein einer Toleranzen von 0,5 auf Unterschiede in „price“. Alle Spalten werden mit Datentypen versehen. Das Nummernformat innerhalb der beiden XML unterscheidet sich auch! .. code-block:: cfg [DEFAULT] newFormat=CSV oldFormat=CSV bothNumberFormat=DE [GLOBAL] resultFormats=HTML oldDirectory=data/old/ newDirectory=data/new/ resultDirectory=results/ [XML_Vergleich] newFormat=XML oldFormat=XML oldNumberFormat=EN newNumberFormat=DE oldFilePath=example017.old.xml newFilePath=example017.new.xml bothKeyColumns=[4|0]_isin,[4|0]_time bothColumnFormats=[4|0]_isin:str,[4|0]_qty:int, [4|0]_time:datetime;%Y-%m-%d %H:%M:%S, [4|0]_price:float, [4|0]_premium:float, [4|0]_cpty:str, [4|0]_cpty_id:int, [4|1]_isutc:bool newIgnoreColumns=[4|0]_fx absoluteColumnsTolerances=[4|0]_price:0.5 keepTempFiles=True TAR Format ------------------------------------------------------------------------------------------------------------------------ Vergleich nur die ‚py‘ Dateien innerhalb zweier Tar Archive .. code-block:: cfg [DEFAULT] bothNumberFormat=EN newFormat=CSV [GLOBAL] resultFormats=HTML,CSV,XLS oldDirectory=test/data/old/ newDirectory=test/data/new/ resultDirectory=test/data/result/ [DIR_vs_TAR] oldFormat=TAR.GZ newFormat=TAR.GZ oldFilePath=package_1234.tar.gz newFilePath=rollout.tar.gz oldKeyColumns=NAME,PATH newKeyColumns=NAME,PATH oldIgnoreColumns=MTIME newIgnoreColumns=MTIME bothRowFilters=not(equals(@'EXTENSION'; 'py')) keepTempFiles=True Vergleich einer unkomprimierten Tar Datei mit einer komprimierten .. code-block:: cfg [DEFAULT] bothNumberFormat=EN newFormat=CSV [GLOBAL] resultFormats=HTML oldDirectory=test/data/old/ newDirectory=test/data/new/ resultDirectory=test/data/result/ [DIR_vs_TAR] oldFormat=TAR.GZ newFormat=TAR oldFilePath=package_1234.tar.gz newFilePath=rollout.tar bothKeyColumns=NAME,PATH bothIgnoreColumns=MTIME keepTempFiles=True   Nur die XML Dateien innerhalb einer der beiden TARs vergleichen .. code-block:: cfg [DEFAULT] numberFormat=EN newFormat=CSV [GLOBAL] resultFormats=CSV oldDirectory=test/data/old/ newDirectory=test/data/new/ resultDirectory=test/data/result/ [TarDiff01] oldFormat=TAR newFormat=TAR oldFilePath=ncdiff.tar newFilePath=ncdiff.tar newKeyColumns=NAME oldKeyColumns=NAME newRowFilters=not(equals(@'EXTENSION'; 'xml')) oldRowFilters=not(equals(@'EXTENSION'; 'xml')) keepTempFiles=True Nur die Dateien im Root Verzeichnis der TAR-Archive vergleichen .. code-block:: cfg [DEFAULT] bothNumberFormat=EN newFormat=CSV [GLOBAL] resultFormats=HTML oldDirectory=test/data/old/ newDirectory=test/data/new/ resultDirectory=test/data/result/ [DIR_vs_TAR] oldFormat=TAR.GZ newFormat=TAR.BZ2 oldFilePath=package_1234.tar.gz newFilePath=rollout.tar.bz bothKeyColumns=NAME,PATH bothIgnoreColumns=MTIME bothRowFilters=and(not(equals(@'DEPTH'; 0); not(equals(@'TYPE'; 'File'))) keepTempFiles=True   DIR Format ------------------------------------------------------------------------------------------------------------------------ Vergleich von zwei Verzeichnissen. Abgleichskriterium ist die Position im Verzeichnisbaum und der Name der Datei\Verzeichnis. .. code-block:: cfg [DEFAULT] newNumberFormat=EN newFormat=CSV [GLOBAL] resultFormats=HTML oldDirectory=C:\ newDirectory=test/data/new/ resultDirectory=test/data/result/ [TestReport1] oldFilePath=oldResults newFilePath=newResults oldFormat=DIR newFormat=DIR bothKeyColumns=NAME,RELPATH Vergleich von zwei Verzeichnissen mit dem ignorieren möglicher Unterscheid aus den Zeitstempeln und der Datentypdefinition für alle Spalten. .. code-block:: cfg [DirDiff01] oldFormat=DIR newFormat=DIR oldFilePath=ncdiff\examples\data newFilePath=ncdiff\examples\data newKeyColumns=RELPATH, NAME oldKeyColumns=RELPATH, NAME bothIgnoreColumns=ABSPATH,ATIME,MTIME bothColumnFormats=NAME:str, ABSPATH:str, RELPATH:str, EXTENSION:str, TYPE:int, DEPTH:int, SIZE:int, CTIME:datetime;%Y-%m-%d %H:%M:%S, ATIME:datetime;%Y-%m-%d %H:%M:%S, MTIME:datetime;%Y-%m-%d %H:%M:%S, USER:int, GROUP:int, HASH:str Vergleich von zwei Verzeichnissen nur für Dateien vom Typ ‚py‘. .. code-block:: cfg [DEFAULT] bothNumberFormat=EN newFormat=CSV [GLOBAL] resultFormats=HTML oldDirectory=C:\ newDirectory=test/data/new/ resultDirectory=test/data/result/ [TestReport1] oldFilePath=. newFilePath=. oldFormat=DIR newFormat=DIR bothKeyColumns=NAME,RELPATH bothRowFilters=not(equals(@'EXTENSION'; 'py') Finden von gleichen Dateien anhand von Hash-Summe. .. code-block:: cfg [DEFAULT] newNumberFormat=EN newFormat=CSV [GLOBAL] resultFormats=HTML oldDirectory=C:\ newDirectory=test/data/new/ resultDirectory=test/data/result/ [TestReport1] oldFilePath=oldResults newFilePath=newResults oldFormat=DIR newFormat=DIR bothKeyColumns=HASH bothRowFilters=not(equals(@'TYPE'; 'File')) SQL Format ------------------------------------------------------------------------------------------------------------------------ Dieses Beispiel zeigt den Vergleich zweier EPSVDF Tabellen von unterschiedlichen BAIS Datenbank Versionen auf einem Microsoft SQL Server. .. code-block:: cfg [GLOBAL] resultFormats=CSV,XLS,HTML resultDirectory=results/ [DEFAULT] oldLabel = BAIS 1.13 newLabel = BAIS 1.16 [EPSVDF] bothFormat = SQL oldSQLConnection = DRIVER={SQL Server};SERVER=HOSTNAME;DATABASE=BAIS113;UID=BENUTZERNAME;PWD=PASSWORT newSQLConnection = DRIVER={SQL Server};SERVER=HOSTNAME;DATABASE=BAIS116;UID=BENUTZERNAME;PWD=PASSWORT bothSQLQuery = EPSVDF #bothSQLQuery = select * from EPSVDF bothKeyColumns = EPSVDF_VORDR, EPSVDF_VDRZL, EPSVDF_VDRSP, EPSVDF_INSTA Formatübergreifende Vergleiche ------------------------------------------------------------------------------------------------------------------------ Vergleichen einer XLS mit einer CSV Datei deren interne Struktur gleich ist. .. code-block:: cfg [DEFAULT] bothNumberFormat=EN [GLOBAL] resultFormats=CSV oldDirectory=test/data/old/ newDirectory=test/data/new/ resultDirectory=test/data/result/ [XLS_vs_CSV] oldFilePath=Report1_v1.0.xls newFilePath=Report1_v2.0.csv oldFormat=XLS newFormat=CSV bothKeyColumns=1 Vergleichen einer XML Datei mit einer CSV Datei: .. code-block:: cfg [DEFAULT] bothNumberFormat=EN [GLOBAL] resultFormats=HTML oldDirectory=test/data/old/ newDirectory=test/data/new/ resultDirectory=test/data/result/ [XmlDiff01] oldFilePath=Report01.xml newFilePath=Report01.csv oldFormat=XML newFormat=CSV oldKeyColumns=[3|0]_InstrumentInstID, [3|0]_InstrumentISIN, [3|0]_InstrumentCurr newKeyColumns=InstrumentInstID,InstrumentISIN,InstrumentCurr Vergleichen einer TAR Datei mit einem Verzeichnis: .. code-block:: cfg [DEFAULT] bothNumberFormat=EN newFormat=CSV [GLOBAL] resultFormats=HTML oldDirectory=test/data/old/ newDirectory=test/data/new/ resultDirectory=test/data/result/ [DIR_vs_TAR] oldFormat=TAR.GZ newFormat=DIR oldFilePath=package_1234.tar.gz newFilePath=. oldKeyColumns=NAME,PATH newKeyColumns=NAME,RELPATH oldIgnoreColumns=MTIME newIgnoreColumns=CTIME,ATIME,MTIME,ABSPATH keepTempFiles=True   Benutzung von Umgebungs Variablen in der Konfiguration ------------------------------------------------------------------------------------------------------------------------ Das Pfad zum ``newDirectory`` wird teilweise aus der Umgebungsvariable ``SUBFOLDER`` erzeugt. Die Resultate des Vergleichs werden immer in einem Verzeichnis mit dem aktuellen Datum abgelegt. Die „Old“ Datei wird auf Basis von HEUTE-3 Wochen gesucht, wohingegen für die „New“ Datei einfach nur nach einer Datei die auf das definierte Schema passt gesucht. Die ersten 3 Zeilen werden aus der „New“ Datei herausgeschnitten. .. code-block:: cfg [DEFAULT] oldFormat=CSV newFormat=CSV oldNumberFormat=DE newNumberFormat=US [GLOBAL] resultFormats=HTML oldDirectory=data/old/ newDirectory=data/new/${SUBFOLDER} resultDirectory=results/{%Y-%m-%d} [example009_wildcards] oldFilePath=example009.old.{%Y-%m-%d!-3w}_??????.csv newFilePath=example009.new.??????????_??????.csv newCSVDelimiter=\t oldKeyColumns=1 newKeyColumns=1 oldHasHeader=False newHasHeader=False oldColumnFormats=9:bool newColumnFormats=I:bool newRowFilters=row_range(1;3) keepTempFiles=True Benutzung ResultFilter ------------------------------------------------------------------------------------------------------------------------ Ausfiltern aller Differenzen die durch „Missing in Old“ erzeugt werden und ausfiltern aller Unterschied auf „PV“ die zwischen 0.0 und 0.05 liegen. Zusätzlich sind die Spalten in unterschiedlicher Reihenfolge in den beiden Dateien abgebildet. Alle Unterschiede in der Spalte QTY sollen ignoriert werden wenn in der selben Zeile in CURR „EUR“ steht. Alles Unterschied in CONTRACT die kleiner als 5 sind fallen unter die Toleranzschwelle. .. image:: img/usecases_resultfilter.png .. code-block:: cfg [DEFAULT] newFormat=XLS oldFormat=XLS bothNumberFormat=DE bothCSVDelimiter=; resultFilterFilePath=resultFilter.xls resultFilterXLSSheetName=ResultFilter resultFilterEmptyMarker= [GLOBAL] resultFormats=HTML oldDirectory=data/old/ newDirectory=data/new/ resultDirectory=results/ resultFilterDirectory=filter [example019_csv_vs_xls] oldFormat=CSV newFormat=XLS oldNumberFormat=EN oldFilePath=example019.old.csv newFilePath=example019.new.xls bothKeyColumns=1 bothHasHeader=True newXLSSheetName=data 123 mapColumnIDs=B:D, C:F, D:E, E:G, F:H, G:B, H:C newColumnFormats=G:datetime;%Y-%m-%d %H:%M:%S,H:datetime;%Y-%m-%d %H:%M:%S oldColumnFormats=E:date;%d.%m.%Y, F:datetime;%d.%m.%Y newIgnoreColumns=quantity: contains(@'currency'; 'EUR') showFilteredTolerances=True showFilteredResults=True absoluteColumnsTolerances=contact:5.0 keepTempFiles=True Anzeigen von ausgefilterten Ergebnissen ------------------------------------------------------------------------------------------------------------------------ .. code-block:: cfg [DEFAULT] oldFormat=CSV newFormat=CSV bothNumberFormat=DE bothCSVDelimiter=; [GLOBAL] resultFormats=HTML oldDirectory=data/old/ newDirectory=data/new/ resultDirectory=results/ [example001_csv] oldFilePath=example001.old.csv newFilePath=example001.new.csv oldKeyColumns=1 newKeyColumns=1 keepTempFiles=True showFilteredTolerances=TRUE showFilteredResults=TRUE