6/28/17 Notes (Searching names with apostrophes in them)
- I tried the command I used yesterday, but this time using the “Last Name” column because I know the format of it is text because I fixed it earlier yesterday. This did not work.
- I tried translating As to Ds to see if this command could only translate letters and not symbols. This did not work.
- I tried making Attend = Attendance[‘Full Name’], then str = “Attend” hoping that this would open up the file I wanted to translate but instead it translated the word “Attend”
- Tried this command:
- from string import maketrans
intab = "'"
outtab = "_"
trantab = maketrans(intab, outtab)
print Attendance['Full Name'].translate(trantab)
- This did not work.
- Tried “Attendance.translate(trantab)” instead of “Attendance['Full Name'].translate(trantab)”
- This did not work.
- I tested making str = “Evan O’Brien” and that worked. I think the problem is that the string has to be typed out and I need a command that can go into a file and translate the string in that
- I tried this command:
- f1 = open('ConfidenceS14', 'r')
f2 = open('ConfidenceS14.txt.tmp', 'w')
for line in f1:
- f2.write(line.replace("'", "_"))
- f1.close()
- f2.close()
- Apparently you can search names with apostrophes using \’ and that works so now the problem with some names having the apostrophe and some names not having the apostrophe will be solved when I get the string matching to work
- Example: Search Evan O’Brien as “Evan O\’Brien”
Comments
Post a Comment