I am trying to work with pylabels to create nametags for an upcoming event. In one section of the code, there is this tid-bit:
with open(os.path.join(base_path, "names.txt")) as names:
sheet.add_labels(name.strip() for name in names)
where sheet = labels.Sheet(specs, write_name, border=True). So essentially, this will load each line of "names.txt" and call the function 'write_name', using specifications in 'specs', and add each name to unique labels. I'm attempting to change this code to the following:
with text_file[["Name"]] as names:
sheet.add_labels(name.strip() for name in names)
But I get this error:
Traceback (most recent call last):
File "sticker.V.7.py", line 173, in <module>
with text_file[["Name"]] as names:
AttributeError: __exit__
Can anyone help me understand what exit means in this context? I do not understand from other submissions.
I am hoping to add this subsetting aspect so that I can add further details to the nametags.
I am using Python3.5