Tag: Last
Python : Get Last Modification date & time of a file. | os.stat() | os.path.getmtime()
In this article we will discuss different ways to get the last modification date & time of a file and how to convert them into different formats. Get last modification time of a file using os.stat() os.stat(pathOfFile) It returns the status of file in the form of an os.stat_result object. It contains information related to a …
Python : Get Last Modification date & time of a file. | os.stat() | os.path.getmtime()Read More
Python : How to get Last Access & Creation date time of a file
In this article we will discuss different ways to get the last access and creation timestamp of a file and how to convert them into different formats. os.stat() Python’s os module provides a function os.stat() Advertisements os.stat(pathOfFile) It accepts the path of file as argument and returns the status of file in the form of an …
Python : How to get Last Access & Creation date time of a fileRead More
Pandas : Select first or last N rows in a Dataframe using head() & tail()
In this article we will discuss how to select top or bottom N number of rows in a Dataframe using head() & tail() functions. Select first N Rows from a Dataframe using head() function pandas.DataFrame.head() In Python’s Pandas module, the Dataframe class provides a head() function to fetch top rows from a Dataframe i.e. Advertisements …
Pandas : Select first or last N rows in a Dataframe using head() & tail()Read More
Python: How to get Last N characters in a string?
In this article, we will discuss how to fetch the last N characters of a string in python. This N can be 1 or 4 etc. In python, a String is a sequence of characters, and each character in it has an index number associated with it. For example, we have a string variable sample_str …
Check the first or last character of a string in python
In this article, we will discuss different ways to check the content of the first or last character of a string in python. Indexing in String Every character in a string has an index number associated with it. This index can be a positive or negative number. For example, we have a string, Advertisements sample_str …
Check the first or last character of a string in pythonRead More
Python: Get last N lines of a text file, like tail command
In this article, we will discuss a memory-efficient solution to read the last line or last N lines from a text or CSV file in python. Then we will also see how to real only last line or check if the last line in the file matches the given line. We have created a function …
Python: Get last N lines of a text file, like tail commandRead More
6 ways to get the last element of a list in Python
In this article, we will discuss six different ways to get the last element of a list in python. Get last item of a list using negative indexing List in python supports negative indexing. So, if we have a list of size “S”, then to access the Nth element from last we can use the …
Remove last N characters from string in Python
In this article we will discuss different ways to delete last N characters from a string i.e. using slicing or for loop or regex. Remove last N character from string by slicing In python, we can use slicing to select a specific range of characters in a string i.e. Advertisements str[start:end] It returns the characters …
Python: Remove last element from a list
This article will discuss different ways to delete the last element from a list in Python. Table of Contents Remove the last element from a list in Python using the pop() function Remove the last element from a list in Python using slicing Remove the last element from a list in Python using del keyword …
Linux: Find files modified in last N minutes
In this article, we will discuss how to find files in Linux / Unix, that are modified in last few minutes using the find command. Table of Contents Overview of find command in Linux. Syntax of find command with “-mmin n” option. Find files modified in last 5 minutes in Linux. Find files modified in …