csv - Readable display of the filename using python -
i using code below extract file names directory , print them. however, print not easilly readable , wondering if me think of better way display seperating it. question how seperate file name using python?
from os import listdir def find_csv_filenames( path_to_dir, suffix=".csv" ): filenames = listdir(path_to_dir) return [ filename filename in filenames if filename.endswith( suffix ) ] filenames = find_csv_filenames('c:\users\aclayton\aug') name in filenames: print name which gives filename agusta_aw149_ground_2011_7_29_14_50_0.csv.
i read name=augusta test=ground date =29/7/2011. many file names have same format/order, 'test' 'ground' change , date.
thanks help
if sure every filename have attribute order, can use
name.split('_') and organize new strings prefer. instance, in case like:
sep_names = name.split('_') name = 'name='+sep_names[0] test = 'test='+sep_names[2] data = 'date='+sep_names[5]+'/'+sep_names[4]+'/'+sep_names[3]
Comments
Post a Comment