0
output_file_name = '{}__output1.xlsx'.format(str(in_file.resolve().stem))

output_file_path = str(Path(out_folder, output_file_name))

this code lines are giving the following error:

AttributeError: 'str' object has no attribute 'resolve'

I am processing multiple files and trying to dynamically create a file name for the output files and the path for them. Need your help to sort out the error.

I am trying to save the file in the following way:

df.style.applymap(color_code).\to_excel(output_file_path, engine="xlsxwriter")

1
  • See this. I mean especially the comment by Salo. Commented Jul 7, 2020 at 19:21

1 Answer 1

0

resolve() is a method on Path objects from Python's stdlib pathlib module. You should be able to fix it by converting the str to a Path object.

from pathlib import Path

output_file_name = '{}__output1.xlsx'.format(Path(in_file).resolve().stem)

output_file_path = str(Path(out_folder, output_file_name))
Sign up to request clarification or add additional context in comments.

2 Comments

I did change the code as per your suggestion but it is still giving the same error.
I just edited my answer, notice the placement of the parentheses.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.