Jovian
⭐️
Sign In
In [9]:
import csv
a=list(csv.reader(open('2.csv','r')))
print(a)
s=['$','$','$','$','$','$']
g=[['?','?','?','?','?','?']]
for i in range(len(a)):
    if(a[i][6]=="Y"):
        for j in range(len(s)):
            if(s[j]=='$'):
                s[j]=a[i][j]
               
            elif(s[j]!=a[i][j] and s[j]!="?"):
                for k in range(len(g)):
                    if g[k][j]==s[k]:
                        g.pop(k)
                        break
                s[j]="?"
        print("The specific array at {} is".format(i), s)
        print("The general array at {} is".format(i), g)
    elif(a[i][6]=="N"):
        for j in range(len(s)):
            b=['?','?','?','?','?','?']
            if g[0]==b:
                g.pop(0)
            if(s[j]!='?'and s[j]!=a[i][j]):
                b[j]=s[j]
                g.append(b)
        print("The specific array at {} is".format(i), s)
        print("The general array at {} is".format(i), g)

[['Sky', 'AirTemp', 'Humidity', 'Wind', 'Water', 'Forecast', 'EnjoySport'], ['sunny', 'warm', 'normal', 'strong', 'warm', 'same', 'Y'], ['sunny', 'warm', 'high', 'strong', 'warm', 'same', 'Y'], ['rainy', 'cold', 'high', 'strong', 'warm', 'change', 'N'], ['sunny', 'warm', 'high', 'strong', 'cool', 'change', 'Y']] The specific array at 1 is ['sunny', 'warm', 'normal', 'strong', 'warm', 'same'] The general array at 1 is [['?', '?', '?', '?', '?', '?']] The specific array at 2 is ['sunny', 'warm', '?', 'strong', 'warm', 'same'] The general array at 2 is [['?', '?', '?', '?', '?', '?']] The specific array at 3 is ['sunny', 'warm', '?', 'strong', 'warm', 'same'] The general array at 3 is [['sunny', '?', '?', '?', '?', '?'], ['?', 'warm', '?', '?', '?', '?'], ['?', '?', '?', '?', '?', 'same']] The specific array at 4 is ['sunny', 'warm', '?', 'strong', '?', '?'] The general array at 4 is [['sunny', '?', '?', '?', '?', '?'], ['?', 'warm', '?', '?', '?', '?']]
In [ ]: