Skip to content

Instantly share code, notes, and snippets.

@JakubVanek
Created July 17, 2020 13:22
Show Gist options
  • Save JakubVanek/7093794efe6557aa2f8b593887c0e3e7 to your computer and use it in GitHub Desktop.
Save JakubVanek/7093794efe6557aa2f8b593887c0e3e7 to your computer and use it in GitHub Desktop.
Compare two CSVs
import sys
import pandas as pd
import numpy as np
def main():
if len(sys.argv) != 3:
print("Chyba: očekávány dva argumenty", file=sys.stderr)
print("Použití:", file=sys.stderr)
print(f"{sys.argv[0]} <csv sklad> <csv pokladna>", file=sys.stderr)
sys.exit(1)
csvSklad = sys.argv[1]
csvPokla = sys.argv[2]
dataSklad = pd.read_csv(csvSklad, delimiter=',', index_col='kod', header=0, names=['kod', 'nazev sklad', 'bla1 sklad', 'cena sklad'])
dataPokla = pd.read_csv(csvPokla, delimiter=',', index_col='kod', header=0, names=['kod', 'nazev pokladna', 'bla1 pokladna', 'cena pokladna'])
joined = dataSklad.join(dataPokla, how='inner')
problems = joined.loc[ joined['cena sklad'] != joined['cena pokladna'] ]
formatted = problems[['nazev sklad', 'cena sklad', 'cena pokladna']]
print("Změny ceny:")
print(formatted.to_string())
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment