Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- f = open('C:\\Users\\kced20\Desktop\\myread\\international.csv',"r") # this line will open the file international.csv for reading
- out = open("females.csv","w") # this line will create a file called females.csv
- counterfemale_of_china = 0 # counter of chinese females
- for line in f: # this line means loop thru each line of international.csv
- line = line.strip() # this line means that clean each line read, meaning that remove all hidden spaces, tab ....
- a,b,c,d,e,f = line.split(",") # this line means a = id, b =firstname, c= lastname, d=email , e= gender and f = country
- if (e == 'Female'): # since we know that variable e is the gender, then we compare e to Female to see if male or female
- out.write(line) # if gender = female, then write the female line information to females.csv
- if (e == 'Female' and f =='China'): # since we know that e is gender and f is country, then this line means find all female from China
- counterfemale_of_china = counterfemale_of_china + 1 # this line means count the number of females and chinese
- print("The number of Chinese Female is :\t",counterfemale_of_china)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement