Skip to content

Instantly share code, notes, and snippets.

@UweZiegenhagen
Last active May 9, 2021 08:02
Show Gist options
  • Select an option

  • Save UweZiegenhagen/1d7c4fe09e289bc1afb3ef8f7c199a35 to your computer and use it in GitHub Desktop.

Select an option

Save UweZiegenhagen/1d7c4fe09e289bc1afb3ef8f7c199a35 to your computer and use it in GitHub Desktop.
Medium-20210509-2.py
# load both files into separate dataframes
file1 = pd.read_csv('file1.csv', sep=';', encoding='UTF-8')
file2 = pd.read_csv('file2.csv', sep=';', encoding='UTF-8')
# save the list of column names for each dataset
columnnames1 = list(file1)
columnnames2 = list(file2)
# check if the columns match
if collections.Counter(columnnames1) == collections.Counter(columnnames2):
print ("Number of columns and Names match, Comparison possible...\n\n")
else:
print ("Number of columns and Names are not matching!!! Please check the input!")
sys.exit('Error!')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment