I have N number of .txt files each having thousands of IP addresses in a directory(for eg. /var/logs). The file's name starts with 'log', for example, log01.test.co.net, log02.hello.co.net, log01.domain.co.net, etc. I need to add the IPs from each .txt file as a column to an excel file and compare all the columns to find the common IPs. Then print the common IPs as another column called "Common IPs".
How can I achieve the requirement with the Python Pandas library? Can anyone please help?
I am new to Python and was able to find from the web that we can convert txt files into excel format using the Python Pandas library.
#!/usr/bin/env python3
import pandas as pd
df = pd.read_table('log01.txt')
df.to_excel('output.xlsx', 'Sheet2')