Retrieval of latest file


I am attempting to grab the latest generated file from a designated location(in json format) and opening it. I can easily retrieve the file directly but am having trouble using the proper keywords for grabbing the latest file via year month day time etc etc

current code:

@{files}=   List Files In Directory    "Path"
${lastmodifiedfile}=   Get From List   ${files}  0-
@{time}=  Get Modified Time   ${files}   year,month,day,hour,min,sec
${json_file}=   Load JSON From File     ${time}
${value}=   get value from json    ${json_file}     $.Data

log to console  ${value[0]}  
${results}=  convert to string   ${value}
Append To File   "path"

What i am getting is “ValueError: Cannot convert index ‘0-’ to an integer” ← could be the fact that I am grabbing a .json. but i am speculating here.

Any assistance is greatly appreciated… Thanks

Your “Get From List” has 0- as index and error message you get is ValueError: Cannot convert index ‘0-’ to an integer

Did you try to remove the - character from the index parameter ?

1 Like

I did yes. I actually tried that first. Got this error

“IndexError: Given index 0 is out of the range 0–1.”

This is why I tried the “0-”

This is fixed… Thank you for the assistance !

I am having the same issue. How did you fix this please?