Package: csvcomparer
csvcomparerCompare delimited files that share a common key.Explore the docs »·Report Bug·Request FeatureTable of ContentsOverviewExampleInstallationRoadmapContributingLicenseContactAcknowledgmentsOverviewcsvcompareris an open-source Python project used for determining differences between two delimited files (referred to here as "left" and "right" files) that share a common key, or index. Specifically,csvcomparerdetermines:Columns exclusive to the left and right files, respectively.Rows exclusive to the left and right files, respectively.Field-level differences for rows/columns in common between files.(back to top)Basic UsageAs a python module:fromcsvcomparerimportCsvComparediffs=CsvCompare("<path/to/left_file.csv>","<path/to/right_file.csv>","<key>").diffsAs a command line utility:> python csvcomparer left_csv_filepath right_csv_filepath keyExamplesProvided the following file data:menu_l.csvidnamepicpricescoretogo1Abeer🍺$6.003.9N1Bwine🍷$7.254.5N2Acheese🧀$4.104.0Y3Abacon🥓$3.334.9Ymenu_r.csvidnamepicpricestars1Abeer🍻$5.253.91Bwine🍷$7.254.82Acheese🧀$3.954.14Ctaco🌮$8.333.15Bpizza🍕$9.992.4Usage as a Python module...>>>fromcsvcomparerimportCsvCompare>>>CsvCompare("menu_l.csv","menu_r.csv","id").diffs... or as a command-line utility:>pythoncsvcomparermenu_l.csvmenu_r.csvidReturns:{'cols_added':['stars'],'cols_removed':['score','togo'],'rows_added':{'4C':{'name':'taco','pic':'🌮','price':'$8.33','stars':3.1},'5B':{'name':'pizza','pic':'🍕','price':'$9.99','stars':2.4}},'rows_changed':{'1A':[('pic','🍺','🍻'),('price','$6.00','$5.25')],'2A':[('price','$4.10','$3.95')]},'rows_removed':{'3A':{'name':'bacon','pic':'🥓','price':'$3.33','score':4.9,'togo':'Y'}}}Multi-column keys are also supported. So for the same file data:>>>CsvCompare("menu_l.csv","menu_r.csv",["id","name"]).diffsReturns:{'cols_added':['stars'],'cols_removed':['score','togo'],'rows_added':{('4C','taco'):{'pic':'🌮','price':'$8.33','stars':3.1},('5B','pizza'):{'pic':'🍕','price':'$9.99','stars':2.4}},'rows_changed':{('1A','beer'):[('pic','🍺','🍻'),('price','$6.00','$5.25')],('2A','cheese'):[('price','$4.10','$3.95')]},'rows_removed':{('3A','bacon'):{'pic':'🥓','price':'$3.33','score':4.9,'togo':'Y'}}}See the docs for detailed usage and examples.(back to top)InstallationPrerequisitesPythonv3.6 or greaterPoetryThen simply run:poetryinstallcsvcomparer(back to top)Roadmapcsvcompareris in its infancy, and there are high hopes for this project!The ultimate goal is being able to compare any two data sets that can be consumed as a "dataframe", regardless of size, efficiently as possible. This comes with a great deal of challenges, but I'm confident it will get there.See theopen issuesfor a full list of proposed features (and known issues).(back to top)ContributingAny contributions aregreatly appreciated.If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement".
Don't forget to give the project a star! Thanks again!Fork the ProjectCreate your Feature Branch (git checkout -b feature/AmazingFeature)Commit your Changes (git commit -m 'Add some AmazingFeature')Push to the Branch (git push origin feature/AmazingFeature)Open a Pull Request(back to top)LicenseDistributed under the MIT License. SeeLICENSE.txtfor more information.(back to top)ContactRyan Bergsmith -LinkedIn-ryguydev@gmail.comProject Link:Github(back to top)AcknowledgmentsRobin Zaubeererfor being a greatPDMcoach and providing roadmap inspiration.(back to top)