- Trending Categories
- Data Structure
- Operating System
- C Programming
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Interpreting stat() results using Python
The stat() method is part of OS module which describes various OS related operations on files and directories. For example, if we want to know various user defined flags for a file or size of the file in bytes.
Functions in os.stat() module
Below is a list of some sample functions available in stat() and their meaning.
st_size − It represents the size of the file in bytes.
st_atime − It represents the time of most recent access. It is expressed in seconds.
st_ctime − It represents the time of most recent metadata change on Unix and creation time on Windows. It is expressed in seconds.
st_blocks − It represents the number of 512-byte blocks allocated for file.
st_uid − It represents the user identifier of the file owner.
st_gid − It represents the group identifier of the file owner.
st_dev − It represents the identifier of the device on which this file resides.
st_flags − It represents the user defined flags for file.
In the below program we will see how some of the above functions are used.
import os # Choose a file path = 'E:\\customers.csv' # Get the status status = os.stat(path) # Print the result print(status)
Running the above code gives us the following result −
os.stat_result(st_mode=33206, st_ino=1125899906970419, st_dev=1614938858, st_nlink=1, st_uid=0, st_gid=0, st_size=261693, st_atime=1593271710, st_mtime=1593271710, st_ctime=1593271710)
- How to get stat of a file using Python?
- stat() function in PHP
- How can Tensorflow be used to visualize training results using Python?
- How can Tensorflow be used to plot the results using Python?
- How to Visualize API results with Python
- Get all results using WHERE clause in MySQL?
- How to plot 2d FEM results using matplotlib?
- VBA Code to get results
- Order MySQL results without identifier?
- How to merge MySQL results?
- Analyzing Monitor Results in Postman
- Learn How to Use http stat to Find out Website’s Performance
- Program to find Fibonacci series results up to nth term in Python
- Removing _id element from PyMongo results?