How do I loop through files in Python to identify and count duplicates? -


i have bunch of files record number of instances file occurs. here sample of data have:

sample of data

i want code run through these files , record output follows in separate excel file:

    name               date      number of files     marketdataserver   30012013  2     marketdataserver   30032013  1     .     .     .     .     netstat            01012013  5     netstat            01022012  3 

is there way in can done using python script?

you can create like:

import os d = {} current_dir in [dir1, dir2, dir3..]  # iterates on directories files     files = os.listdir(current_dir)      fi in files:         if fi in d.keys():             d[fi] += 1  # there, let's increment         else:            d[fi] = 1  # new file  k, v in d.items():  # let's print file stats     print 'file:', k, 'count':' v 

Comments

Popular posts from this blog

python - Selenium remoteWebDriver (& SauceLabs) Firefox moseMoveTo action exception -

html - How to custom Bootstrap grid height? -

transpose - Maple isnt executing function but prints function term -