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")

BP09
  • 11
  • 4
  • See [this](https://stackoverflow.com/questions/32838760/how-to-resolve-relative-paths-in-python). I mean especially the comment by Salo. – Mike O'Connor Jul 07 '20 at 19:21

1 Answers1

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))
iLoveTux
  • 3,552
  • 23
  • 31