Python operates HDFs and obtains the basic properties of the HDFs file name and file, including the modification time and conversion to standard Time

Source: Internet
Author: User

Using Anaconda to install Python HDFs package Python-hdfs 2.1.0 Package

From HDFs Import *
Import time

Client = Client ("http://192.168.56.101:50070")
ll = client.list ('/home/test ', status=true)
For I in LL:
table_name = i[0] #表名
table_attr = i[1] #表的属性
#修改时间1528353247347, 13 bits to milliseconds, need to be converted to a timestamp of 10 bits to seconds (float type required)
table_modify_time=table_attr[' Modificationtime ']/1000.0
#使用localtime () and formatted output strftime () convert timestamps to normal format
Table_modify_time_format=time.strftime ('%y-%m-%d%h:%m:%s ', Time.localtime (table_modify_time))
Print (table_name)
Print (TABLE_ATTR)
Print (table_modify_time) #表的修改时间, sec
Print (Table_modify_time_format) #表的修改时间, formatted output
Print (")


The output is:

test_sh-fang20180604150605.sh
{u ' group ': U ' supergroup ', U ' permission ': U ' 644 ', U ' blockSize ': 134217728, U ' accesstime ': 1530720024452L, U ' pathsuffix ' : U ' test_sh-fang20180604150605.sh ', U ' modificationtime ': 1528095968096L, U ' replication ': 3, U ' length ': Ten, U ' Childrennum ': 0, U ' owner ': U ' appuser ', U ' storagepolicy ': 0, U ' type ': U ' FILE ', U ' fileId ': 26941}
1528095968.1
2018-06-04 15:06:08

Python operates HDFs and obtains the basic properties of the HDFs file name and file, including the modification time and conversion to standard Time

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.