algorithmic modeling for Rhino
Hi
I have one question for scripting.
Is rhino python support sort time ??? I have a list of text files by different time inside one folder. I want grasshopper script to read the latest text file inside one folder.
I have check some solution in python
here is example :
files = os.listdir(".")
files.sort(key=os.path.getmtime, reverse=True)
for name in files: with open(name) as f:
if search_string in f.read():
print name
break
anyway to translate to rhinopython code ???
many thanks.
best,
Carl
Tags:
hi Carl, can you try this one?
import os
path = 'c:/python-test/' #change this pathfiles = os.listdir(path + '.')
files = [path+x for x in files]
files = sorted(files,key=os.path.getmtime)[::-1]for i in files:
print i
Carl,
It's not a problem with your 'import' call. It's a problem with indentation.
It looks like form your picture that you have a tab in front of "import os". And all of the other lines for that matter...
Check out the indentation rules for coding in Python here:
Welcome to
Grasshopper
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
© 2024 Created by Scott Davidson. Powered by