csv - Python reading unicode folder and file names -
i new python. trying input 1 path , use os.walk()
search files, , return files' names. want use os.path.getsize()
file size, , finally, write them csv file.
however, if file name not in english, in chinese, german, french, etc, python cannot recognize , not return size of file. i'd use os.path.getsize(path)
(referring example below), not recognize file's name. how can let python recognize file's name , return size of these kind of files?
for example: file's name is: "Показатели естественного и миграционного прироста до 2030г.doc"
. path="c:\xxxx\xxx\xxxx\Показатели естественного и миграционного прироста до 2030г.doc"
if pass unicode input os.walk()
file-names unicode well.
the following should work you
your_base_path = u"c:\\directory" # note unicode root, dirs, files in os.walk(your_base_path): f in files: print os.stat(os.path.join(root, f)).st_size
Comments
Post a Comment