I have 2 CSV files with same number of columns and formats containing details about servers in each row. Each file refers to a different Day.
I want to compare each of the servers (rows) of the Day2 CSV file for the Size (GB) column (column D) against each server of the Day1 CSV file for the Size (GB) column (column D), and write the output in either column E of day2 CSV file or in a separate 3rd CSV file to track the difference/growth in size every day.
I am trying to achieve it in Python.
Next I provide an example:
day1.csv
Server Site Platform Size(GB)
a Primary Windows 100
b Secondary Unix 200
c Primary Oracle 500
day2.csv
Server Site Platform Size(GB)
a Primary Windows 150
b Secondary Unix 100
c Primary Oracle 500
Expected Result output.csv
Server Site Platform Size(GB) Growth(GB)
a Primary Windows 150 50
b Secondary Unix 100 -100
c Primary Oracle 500 0
EDIT 1:
This is the code I have developed so far:
import csv
t1 = open('/day1.csv', 'r')
t2 = open('/day2.csv', 'r')
outputt=open("/growth.csv","w")
fileone = t1.readlines()
filetwo = t2.readlines()
for line in filetwo:
row = row.split(',')
a = str(row[0])
b = str(row[1])
c = str(row[2])
d = float(row[3])
f = float(filetwo.row[3] - fileone.row[3])
outputt.writerow([a,b,c,d,e,f])
outputt.write(line.replace("\n","") + ";6column\n") outputt.close()
fileone.close()