Package: diffino
diffinoDiffing tools for comparing datasets in CSV, XLSX and other formats available as CLI app, API, web app and module. Powered by the awesome Pandas library for Python.DoneInstall as CLI appInstall and use as python moduleCompare two CSV datasets using Pandas where you can output differences row by rowUse the following inputs for your datasets:Local file in CSV pandas modesFile in S3 pandas modeDefine a subset of columns to use for comparing/diffing (only works with pandas mode, not supported for MD5 comparison)Output differences to:Console (print)CSV fileTo-Do (ROADMAP)Compare one or more CSV datasets using MD5 hash of the filesCompare one or more XLSX datasets using Pandas where you can output differences row by rowUse the following inputs for your datasets:Local file in CSV MD5Local file in XLSX (only for pandas mode)Local directory with CSVs or XSLX files (for both MD5 and pandas modes)ZIP file with CSVs or XLSX files (only for pandas mode)File in S3 for MD5Bucket in S3 (for both MD5 and pandas modes)Output differences to:XSLX fileJSON fileInstallTo install as module and CLI:pip install diffinoCLIDiffino will try it's best to guess your input storage mechanisms, for that you need to includes3://in the input argument and/or the.csv,.xlsand.xlsx extensions.Compare using pandasMD5 is only useful for knowing two CSV datasets are not the same but it's not useful for knowing which are the actual differences among those. For that you can use the pandas mode which will output the differences row by row.
The same commands shown earlier for MD5 are available, you need to pass the--mode pandasargument for using pandas.By default Pandas mode is used so this argument can be omitted:diffino before_dataset.csv after_dataset.csv --mode pandasWhen using pandas mode, by default Diffino will try to convert numeric columns, you can change this behavior with:diffino before_dataset.csv after_dataset.csv --convert-numeric falseYou can define the columns to be used for checking the diffs:diffino before_dataset.csv after_dataset.csv --cols id nameCompare two CSV files in an S3 bucket using pandas modediffino s3://bucket/before_dataset.csv s3://bucket/after_dataset.csv --mode pandasOutput diff results to fileDiffino will try it's best to guess your output storage mechanism, for that you need to includes3://in the input argument or use the.csv,.xlsand.xlsx extensions.Output to a local CSV filediffino file_1.csv file_2.csv --output diff.csvNote: Two files are going to be generated, comparing the left argument file to the right argument file. For the example above, 2 files are going to be created:diff_left.csvdiff_right.csvAvoid creating unnecesary filesIf you want to avoid unnecesary noise, you can prevent diffino from creating resulting files if there are no actual differences with the--output-only-diffslikediffino file_1.csv file_2.csv --output diff.csvFor the above example, iffile_1has some extra rows that are not present infile_2, butfile_2only have rows that are present infile_1, then we are going to end up only with a resultingdiff_left.csvfile.Output to a local Excel fileWhen using Excel, output will contain different sheets as well as one summary sheet containing all differences:diffino file_1.csv file_2.csv --output diff.xlsxOutput to a local JSON filediffino file_1.csv file_2.csv --output diff.jsonOutput to an CSV file in S3diffino file_1.csv file_2.csv --output s3://bucket/diff.csvOutput to an Excel file in S3When using Excel, output will contain different sheets as well as one summary sheet containing all differences:diffino file_1.csv file_2.csv --output s3://bucket/diff.xlsxOutput to a JSON file in S3diffino file_1.csv file_2.csv --output s3://bucket/diff.jsonPython moduleUseful if you want to integrate as part of you ETL or as part of you Continuous Integration (CI) builds.Get a dictionary with differences using pandas modeFor using all columns:fromdiffino.modelsimportDiffinodiffino=Diffino(left='s3://bucket/one.csv',right='s3://bucket/two.csv',mode='pandas')results=diffino.build_diff()In the above example, theresultsvariable contains a tuple with the first index containing
the left differences count and the second index with the right differences count:results(0)results(1)And for using a subset of columns you can specify a string with a Python list of the column names you want to include:fromdiffino.modelsimportDiffinodiffino=Diffino(left='one.csv',right='two.csv',mode='pandas',cols=['id','name'])results=diffino.build_diff()COMING SOONDifferent column names? No problemo that works too!fromdiffino.modelsimportDiffinodiffino=Diffino(left='one.xlsx',right='two.xlsx',mode='pandas',left_cols=['myColumn'],right_cols=['my_column'],)results=diffino.build_diff()Web AppComing soonAPIComing soon