Posts

Showing posts with the label python-file-methods

Featured Post

SQL Interview Success: Unlocking the Top 5 Frequently Asked Queries

Image
 Here are the five top commonly asked SQL queries in the interviews. These you can expect in Data Analyst, or, Data Engineer interviews. Top SQL Queries for Interviews 01. Joins The commonly asked question pertains to providing two tables, determining the number of rows that will return on various join types, and the resultant. Table1 -------- id ---- 1 1 2 3 Table2 -------- id ---- 1 3 1 NULL Output ------- Inner join --------------- 5 rows will return The result will be: =============== 1  1 1   1 1   1 1    1 3    3 02. Substring and Concat Here, we need to write an SQL query to make the upper case of the first letter and the small case of the remaining letter. Table1 ------ ename ===== raJu venKat kRIshna Solution: ========== SELECT CONCAT(UPPER(SUBSTRING(name, 1, 1)), LOWER(SUBSTRING(name, 2))) AS capitalized_name FROM Table1; 03. Case statement SQL Query ========= SELECT Code1, Code2,      CASE         WHEN Code1 = 'A' AND Code2 = 'AA' THEN "A" | "A

6 Python file Methods Real Usage

Image
Files always have data in them. For different purposes, you need methods to deal with them. These six file methods of use in this case. Related:  5 top file modes in python. Python file methods Below are the top six file methods in python: Tell() Seek() Flush() Fileno() truncate() isatty() 1. tell() The usage of tell method is it  returns the cursor-position of the file-pointer from the beginning of the file. It tells the current cursor position. The position starts from zero, which is same as of an index. Syntax:  fileobject.tell() 2. seek() The usage of seek  method is cursor position, from one position to the specified position from the beginning of the file, it moves. Here, the cursor will be sought to a particular location. Syntax:  fileobject.seek(position) 3. flush() The usage of flush  method is clean out the internal buffer. Before writing the text in the file, it is best practice to clear out that the internal buffer can be cleared. Syntax:  fileobject.flush() 4. fileno() The