with open(Path, encoding=‘utf8’, newline=‘’) as csvfile:
reader = csv.DictReader(csvfile)
for row in reader:
"""print(row['WorksetName'])"""
workset_names.append(row['WorksetName'])
print(workset_names)
if doc.IsWorkshared:
t = DB.Transaction(doc, “Create Worksets”)
t.Start()
# make your model changes here
for name in workset_names:
ws = create_workset(doc, name)
"""if "Hidden" in name:
set_workset_default_visiblity(doc, ws, False)"""
t.Commit()
I did not try your code but the RPS tells you to change the encoding argument of the open() function
change your with open ([...], encoding='utf-8',[...])
at least that is what the Exception Thrown mentions on the first line after the >>> in the RPS windows. Advice here, these exceptions are usually fairly explicit if you take the time to read it. in your case _ even though it is not always the case, it is quite explicit:
open() has a bad keyword argument for the encoding argument.
The open that you are using is the bultin lowlevel open function in python. The one that has the encoding= parameter, is from the codecs module that is designed to wrap the builtin open to allow for automatic handling of various encodings:
import codecs
with codecs.open(file_path, encoding='utf-8') as csv_file_handle:
# ....