AnsweredAssumed Answered

Python Implementation Question

Question asked by samlee916 on Dec 23, 2019
Latest reply on Jan 3, 2020 by blake.terhune

Hello I am trying to figure out the if there is a way to compare two excel file's dates/time?

I wrote a python script, attached below, that downloads a excel file from a website and when I run it again

it pushed the file that was downloaded first to an archived folder and the new file that gets downloads foes to where the old was was originally at and it becomes am excel to csv file in the end.

Excel File Link: https://www.gosolarcalifornia.ca.gov/equipment/documents/Grid_Support_Inverter_List_Full_Data.xlsm 

Website Link: Inverters 

 

I got this idea so far:import pandas as pd
#Reading two Excel Sheets

sheet1 = pd.read_excel(r'Book1.xlsx')
sheet2 = pd.read_excel(r'Book2.xlsx')

# Iterating the Columns Names of both Sheets
for i,j in zip(sheet1,sheet2):

# Creating empty lists to append the columns values
a,b =[],[]

# Iterating the columns values
for m, n in zip(sheet1[i],sheet2[j]):

# Appending values in lists
a.append(m)
b.append(n)

# Sorting the lists
a.sort()
b.sort()

# Iterating the list's values and comparing them
for m, n in zip(range(len(a)), range(len(b))):
if a[m] != b[n]:
print('Column name : \'{}\' and Row Number : {}'.format(i,m))

 

Is there a way I can do this logic:
if(file1 != file2):
   run script

else

   do nothing

It's the conditional statement that I am stuck on.

*file 1 is the excel on the website and file 2 is the download excel file on the computer

Attachments

Outcomes