python - number of rows in two files different--> make equal by deleting from end -


 open(filename,"r") f:        reader = csv.reader(f,delimiter = ",")        data = list(reader)        rownum = len(data)  open(filename2,"r") f:        reader2 = csv.reader2(f,delimiter = ",")        data2 = list(reader2)        rownum2 = len(data)   if rownum > rownum2:        delete(rownum until rownum = rownum2 @ end) 

it's pretty simple.

data = data[:max(rownum, rownum2)] data2 = data2[:max(rownum, rownum2)] 

Comments

Popular posts from this blog

sequelize.js - Sequelize group by with association includes id -

android - Robolectric "INTERNET permission is required" -

java - Android raising EPERM (Operation not permitted) when attempting to send UDP packet after network connection -