code-rag-bench/online-tutorials huggingface dataset:
How to generate Json File in PHP ?

21 May, 2021
In this article, we are going to generate a JSON file in PHP by using an array. JSON stands for JavaScript object notation, which is used for storing and exchanging data. JSON is text, written with JavaScript object notation.
Structure:
{"data":[
 { "sub_data1":"value1", "sub_data2":"value2","sub_data_n":"value n" },
 { "sub_data2":"value2","sub_data2":"value2", "sub_data_n":"value n" },
 { "sub_data n":"value n ", "sub_data2":"value2","sub_data_n":"value n" }
]}
Example:
[{"id":"7020","name":"Bobby","Subject":"Java"},
 {"id":"7021","name":"ojaswi","Subject":"sql"}]
Properties:
JSON doesn’t use an end tagIt is shorter.It is quicker to read and write.It can use arrays.
JSON doesn’t use an end tag
It is shorter.
It is quicker to read and write.
It can use arrays.
Approach: In this article, we can generate JSON data using an array., create an array
Syntax:
$array = Array (
   "number" => Array (
       "data1" => "value1",
       "data2" => "value2",
       "data n" => "valuen"
   ),
   "number" => Array (
      "data1" => "value1",
      "data2" => "value2",
      "data n" => "valuen"
   )
);
Example:
$array = Array (
   "0" => Array (
       "id" => "7020",
       "name" => "Bobby",
       "Subject" => "Java"
   ),
   "1" => Array (
        "id" => "7021",
       "name" => "ojaswi",
       "Subject" => "sql"
   )
);
Use json_encode() to convert array to JSON. It is used to convert array to JSON
Syntax:
json_encode(array_input);
Example: Place the file in the path using file_put_contents()
$json = json_encode($array);
The file_name is the JSON to be saved and json_object is the object after JSON from the array is created.
Syntax:
file_put_contents(file_name.json.json_object);
Example:
file_put_contents("geeks_data.json", $json);
PHP code:
PHP
<?php     // input data  through array$array = Array (    "0" => Array (        "id" => "7020",        "name" => "Bobby",        "Subject" => "Java"    ),    "1" => Array (         "id" => "7021",        "name" => "ojaswi",        "Subject" => "sql"    ));  // encode array to json$json = json_encode($array);//display it echo "$json";//generate json filefile_put_contents("geeks_data.json", $json);  ?>
Output:
[{"id":"7020","name":"Bobby","Subject":"Java"},
 {"id":"7021","name":"ojaswi","Subject":"sql"}]
The JSON file is created in your path.
The JSON file is created in your path.
The data present in the created filegeeks_data
The data present in the created file
geeks_data
JSON
PHP-function
PHP-Questions
Picked
PHP
Web Technologies
PHP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to execute PHP code using command line ?
PHP in_array() Function
How to delete an array element based on key in PHP?
How to Insert Form Data into Database using PHP ?
How to convert array to string in PHP ?
Installation of Node.js on Linux
Top 10 Projects For Beginners To Practice HTML and CSS Skills
Difference between var, let and const keywords in JavaScript
How to insert spaces/tabs in text using HTML/CSS?
How to fetch data from an API in ReactJS ?
Ruby | DateTime strptime() function

09 Jan, 2020
DateTime#strptime() : strptime() is a DateTime class method which parses the given representation of date and time with the given template
Syntax: DateTime.strptime()
Parameter: DateTime values
Return: parses the given representation of date and time with the given template
Example #1 :
# Ruby code for DateTime.strptime() method  # loading libraryrequire 'date'  # declaring DateTime valuedate_a = DateTime.strptime('10-02-2015 05:05:06 PM', '%d-%m-%Y %I:%M:%S %p')  # declaring DateTime valuedate_b = DateTime.strptime('2018 02 3 07 10 09 +7', '%Y %U %w %H %M %S %z')    #  strptime methodputs "DateTime strptime form : #{date_a}\n\n"  puts "DateTime strptime form : #{date_b}\n\n"
Output :
DateTime strptime form : 2015-02-10T17:05:06+00:00

DateTime strptime form : 2018-01-17T07:10:09+07:00


Example #2 :
# Ruby code for DateTime.strptime() method  # Ruby code for DateTime.strptime() method  # loading libraryrequire 'date'  # declaring DateTime valuedate_a = DateTime.strptime('2010 04 6 04 05 06 +7', '%Y %U %w %H %M %S %z')  # declaring DateTime valuedate_b = DateTime.strptime('-1', '%s')    #  strptime methodputs "DateTime strptime form : #{date_a}\n\n"  puts "DateTime strptime form : #{date_b}\n\n"
Output :
DateTime strptime form : 2010-01-30T04:05:06+07:00

DateTime strptime form : 1969-12-31T23:59:59+00:00


Ruby DateTime-class
Ruby-Methods
Ruby
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Make a Custom Array of Hashes in Ruby?
Ruby | Enumerator each_with_index function
Ruby | unless Statement and unless Modifier
Ruby For Beginners
Ruby | Array class find_index() operation
Ruby | String concat Method
Ruby on Rails Introduction
Ruby | Types of Variables
Ruby | Array shift() function
Left() and Right() Function in MS Access

02 Sep, 2020
1. Left() Function :In MS Access the Left() function extract the string from the left of the string. In Left() function The string and the no of the string will be passed. And it will return the string of size the pass number from the left of the string.
Syntax :
Left(string, number_of_chars)
Example-1 :
SELECT Left("GEEKSFORGEEKS", 3) AS ExtractString;
Output –
Example-2 :
SELECT Left("GEEKSFORGEEKS", 10) AS ExtractString;
Output –
2. Right() Function :The Right() function works like Left() function but it extracts the string from the right end of the string. In this, the string and the size of the string that will be extracted will pass as a parameter.
Syntax :
Right(string, number_of_chars)
Example-1 :
SELECT Right("GEEKSFORGEEKS", 4) AS ExtractString;
Output –
Example-2 :
SELECT Right("GEEKSFORGEEKS", 8) AS ExtractString;
Output –
DBMS-SQL
SQL
SQL
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
HTML | <th> valign Attribute

22 Feb, 2022
The HTML <th> valign Attribute is used to specify the vertical alignment of text content in a header cell. It is not supported by HTML 5.
Syntax:
<th valign="top | middle | bottom | baseline">
Attribute Value:
top: It sets the table header content to top-align.
middle: It sets the table header content to middle-align.
bottom: It sets the table header content to bottom-align.
baseline: It sets the table header content to baseline. The baseline is the line where most of the characters sit. It is a default value.
Example:
<!DOCTYPE html><html>  <head>    <title>        HTML th valign Attribute    </title></head>  <body>    <h1>GeeksforGeeks</h1>      <h2>HTML th valign Attribute</h2>      <table border="1" width="500">        <tr style="height:100px;">            <th valign="top">NAME</th>            <th valign="center">AGE</th>            <th valign="bottom">BRANCH</th>        </tr>          <tr>            <td>BITTU</td>            <td>22</td>            <td>CSE</td>        </tr>          <tr>            <td>RAKESH</td>            <td>25</td>            <td>EC</td>        </tr>    </table></body>  </html>
Output:
Supported Browsers: The browser supported by HTML <th> valign attribute are listed below:
Google Chrome
Internet Explorer
Firefox
Safari
Opera
chhabradhanvi
HTML-Attributes
HTML
Web Technologies
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
REST API (Introduction)
Types of CSS (Cascading Style Sheet)
Design a Tribute Page using HTML & CSS
HTTP headers | Content-Type
How to Insert Form Data into Database using PHP ?
Installation of Node.js on Linux
Difference between var, let and const keywords in JavaScript
How to fetch data from an API in ReactJS ?
Differences between Functional Components and Class Components in React
Remove elements from a JavaScript Array
Scala Stack apply() method with example

03 Nov, 2019
In Scala Stack class, the apply() method is utilized to return an element at a given position in the stack. The top of the stack corresponds to the element at 0th position and so on.
Method Definition: def apply(idx: Int): A
Return Type: It returns an element at a given position in the stack.
Example #1:
// Scala program of apply() // method    import scala.collection.mutable.Stack    // Creating object object GfG {            // Main method     def main(args:Array[String])     {                    // Creating a stack        val s1 = Stack(1, 2, 3, 4, 5)                    // Print the stack        println(s1)               // Applying apply method            val result = s1.apply(0)                   // Display output        println("Element at 0th position: " + result)        } } 
Stack(1, 2, 3, 4, 5)
Element at 0th position: 1

Example #2:
// Scala program of apply() // method    import scala.collection.mutable.Stack    // Creating object object GfG {            // Main method     def main(args:Array[String])     {                    // Creating a stack        val s1 = Stack("C++", "Java", "Python", "Scala")                    // Print the stack        println(s1)               // Applying apply method            val result = s1.apply(2)                   // Display output        println("Element at 2nd position: " + result)        } } 
Stack(C++, Java, Python, Scala)
Element at 2nd position: Python

Scala
scala-collection
Scala-Method
Scala
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install Scala with VSCode?
Inheritance in Scala
Hello World in Scala
Scala | Traits
Scala | Option
Scala ListBuffer
Scala | Functions - Basics
Introduction to Scala
Scala Sequence
Scala | Case Class and Case Object
Difference between DROP and TRUNCATE in SQL

16 Apr, 2020
Prerequisite – DROP, and TRUNCATE in SQL
1. DROP :DROP is a DDL(Data Definition Language) command and is used to remove table definition and indexes, data, constraints, triggers etc for that table. Performance-wise the DROP command is quick to perform but slower than TRUNCATE because it gives rise to complications. Unlike DELETE we can’t rollback the data after using the DROP command. In the DROP command, table space is freed from memory because it permanently delete table as well as all its contents.
Syntax of DROP command –
DROP TABLE table_name;
2. TRUNCATE :TRUNCATE is a DDL(Data Definition Language) command. It is used to delete all the tuples from the table. Like the DROP command, the TRUNCATE command also does not contain a WHERE clause. The TRUNCATE command is faster than both the DROP and the DELETE command. Like the DROP command we also can’t rollback the data after using the this command.
Syntax of TRUNCATE command –
TRUNCATE TABLE table_name; 
Let’s see the difference between DROP and TRUNCATE command in SQL:-
MKS075
SQL-Clauses
DBMS
Difference Between
SQL
DBMS
SQL
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
File Organization in DBMS | Set 1
File Organization in DBMS | Set 2
File Organization in DBMS | Set 3
Record-Based Data Model
Introduction of B+ Tree
Class method vs Static method in Python
Difference between BFS and DFS
Difference between var, let and const keywords in JavaScript
Difference Between Method Overloading and Method Overriding in Java
Differences between JDK, JRE and JVM
HTML <dd> Tag

17 Mar, 2022
The <dd> tag in HTML stands for definition description and is used to denote the description or definition of an item in a description list. Paragraphs, line breaks, images, links, lists can be inserted inside a <dd> tag. The <dd> tag in HTML is used along with <dl> tag which defines the description list and <dt> tag which defines the terms in the description list. The <dd> tag requires a starting, but the end tag is optional.
Syntax: 
<dd> Contents... </dd>
Example 1: Below programs illustrate the <dd> element in HTML.
HTML
<!DOCTYPE html><html>       <body>        <h1>GeeksforGeeks</h1>        <h2>HTML dd Tag</h2>        <dl>            <dt>Geeks Classes</dt>            <dd>It is an extensive classroom programme             for enhancing DS and Algo concepts.</dd>            <br>            <dt>Fork Python</dt>            <dd>It is a course designed for beginners             in python.</dd>            <br>            <dt>Interview Preparation</dt>            <dd>It is a course designed for preparation            of interviews in top product based companies.</dd>       </dl>      </body></html>                    
Output:  
Example 2: This example uses the <dd> tag with display property.  
HTML
<!DOCTYPE html><html>    <body>        <h1>GeeksforGeeks</h1>        <h2>HTML dd Tag</h2>        <dl>            <dt>Geeks Classes</dt>            <dd style="display: inline; margin-left: 60px">               It is an extensive classroom programme                for enhancing DS and Algo concepts.            </dd>        </dl>    </body></html>                    
Output:  
Supported Browsers: 
Google Chrome
Internet Explorer
Firefox
Opera
Safari
arorakashish0911
shubhamyadav4
HTML-Tags
HTML
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to update Node.js and NPM to next version ?
Top 10 Projects For Beginners To Practice HTML and CSS Skills
How to insert spaces/tabs in text using HTML/CSS?
REST API (Introduction)
Hide or show elements in HTML using display property
How to set the default value for an HTML <select> element ?
How to set input type date in dd-mm-yyyy format using HTML ?
CSS to put icon inside an input element in a form
Types of CSS (Cascading Style Sheet)
HTTP headers | Content-Type
SQL Server | Convert tables in T-SQL into XML

09 Mar, 2021
In this, we will focus on how tables will be converted in T-SQL into XML in SQL server. And you will be able to understand how you can convert it with the help of command. Let’s discuss it one by one.
Overview :XML (Extensible Markup Language) is a markup language similar to HTML which was designed to share information between different platforms. And here, you will understand how you can Convert tables in T-SQL into XML.
Example –Here is a below sample XML Document as follows.
<email>
 <to>Manager</to>
 <from>Sruti</from>
 <heading>Work Status</heading>
 <body>Work Completed</body>
</email>
Converting tables in T-SQL into XML :To Convert tables in T-SQL into XML by using the following steps as follows. Let’s first generate an Employee_Table to store data of few Employees in order to create XML documents. 
Creating table – Employee_Table 
CREATE TABLE Employee_Table  
(  
EmpId int identity(1,1) primary key,  
Name varchar(100),  
Salary int ,  
City varchar(20)  
)  
Inserting data into Employee_Table –
insert into Employee_Table ( Name,City,Salary)
VALUES
('Sruti','Dhanbad',20000),
('Raj','Kerala',25000),
('Rajsekar','Jaipur',50000),
('Prafull','Kochi',250000),
('Tripti','Kolkata',10000),
('Aditya','Mumbai',5000),
('Kiran','Indore',21000)
Reading data to verify –
SELECT * FROM Employee_Table
Output :
Methods of converting tables in T-SQL into XML :There are two common ways to convert data from SQL tables into XML format as follows.
With FOR XML AUTO –The FOR XML AUTO class creates an XML document where each column is an attribute.
SELECT * FROM Employee_Table
FOR XML AUTO
Output :
This query will create a hyperlink as an output. On clicking the link, we will see the following document in a new query window of SSMS as follows.
With FOR XML PATH clauses –FOR XML PATH will create an XML document where each row is embedded into <row> and </row> clause. In each row, each column value is embedded into <ColumnName> and </ColumnName> clauses.
SELECT * FROM Car
FOR XML PATH
Output :
DBMS-SQL
SQL-Server
SQL
SQL
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Converting all strings in list to integers in Python

Sometimes we can have a list containing strings but the strings themselves are numbers and closing quotes. In such a list we want to convert the string elements into actual integers.
The int function takes in parameters and converts it to integers if it is already a number. So we design a for loop to go through each element of the list and apply the in function. We store the final result into a new list.
 Live Demo
listA = ['5', '2','-43', '23']
# Given list
print("Given list with strings : \n",listA)
# using int
res = [int(i) for i in listA]
# Result
print("The converted list with integers : \n",res)
Running the above code gives us the following result −
Given list with strings :
['5', '2', '-43', '23']
The converted list with integers :
[5, 2, -43, 23]
The map function can be used to apply int function into every element that is present as a string in the given list.
 Live Demo
listA = ['5', '2','-43', '23']
# Given list
print("Given list with strings : \n",listA)
# using map and int
res = list(map(int, listA))
# Result
print("The converted list with integers : \n",res)
Running the above code gives us the following result −
Given list with strings :
['5', '2', '-43', '23']
The converted list with integers :
[5, 2, -43, 23]
Map Function in MATLAB

22 Sep, 2021
A map function basically takes the elements of the array and applies a function to each element.  The resultant output is of the same shape as the array, but the values are the result of the function. In MATLAB, there is a similar function called arrayfun(), which we can be used to achieve the same task. The output from this arrayfunc can have any data type.
Syntax:
X = arrayfun(func,A)
Parameters:
fun: It is a function that we are going to map on each element of the array A.
A: It is the array on which we  are going to map the function.
X: In variable X the output is going to be stored from the map function.
Here, arrayfun(funct,A) applies the function funct to the elements of array A. arrayfun then concatenates the outputs from funct into the output array X, so that for the ith element of A, X(i) = funct(A(i)). 
The input argument funct is a function handle to a function that takes one input argument and returns a scalar. 
Let’s take an example for a better understanding:
Example 1:
Matlab
% MAP function in MatLab  % creating a dummy array % on which we are going to map a functionA = [1,2,3,4,5,6,7,8,9,10];  % Applying arrayfun()  output = arrayfun(@(x) x*2, A);  % displaying outputfprintf("output is :");disp(output);
Output:
Applying arrayfun()
In the above function, firstly we have created an array to which we are going to map a custom function. The custom is x*2 i.e. multiply each element in the array by 2.
 Then we are using arrayfun(@(x) x*2, A), lets break down this statement here arrayfun(fun,array) is the general syntax for mapping a function to the array. We are using @(x) and x*2 in the statement where x*2 is the custom function that we are applying and @(x) is acts as each element of that array A. After that, we’re storing the output to a variable and then using fprintf function we printed a string on display and using the disp function we display the output.
Example 2:
Matlab
% MAP function in MatLab  % creating two dummy arrays % on which we are going to map a functionA = [1,2,3,4,5];B = [6,7,8,9,10];  % Applying arrayfun()  output = arrayfun(@(x,y) x*y, A,B);  % displaying outputfprintf("Product is :");disp(output);
Output:
Product to two arrays using arrayfun()
Blogathon-2021
MATLAB-Functions
Picked
Blogathon
MATLAB
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
What’s a broadcast storm?
How to pass data into table from a form using React Components
How to Import JSON Data into SQL Server?
Consensus Problem of Distributed Systems
Difference between write() and writelines() function in Python
Installing MATLAB on Linux
How to Find Index of Element in Array in MATLAB?
Laplacian Filter using Matlab
Boundary Extraction of image using MATLAB
How to Solve Histogram Equalization Numerical Problem in MATLAB?
Charset name() method in Java with Examples - GeeksforGeeks

28 Mar, 2019
The name() method is a built-in method of the java.nio.charset returns the charset’s canonical name.
Syntax:
public final String name()
Parameters: The function does not accepts any parameter.
Return Value: The function returns the charset’s canonical name.
Below is the implementation of the above function:
Program 1:
// Java program to demonstrate// the above function  import java.nio.charset.Charset;import java.nio.charset.CharsetDecoder;import java.nio.charset.CharsetEncoder;  public class GFG {      public static void main(String[] args)    {          // Gets charset        Charset Charset1 = Charset.forName("UTF8");          // Prints it        System.out.println(Charset1.name());    }}
UTF-8

Program 2:
// Java program to demonstrate// the above function  import java.nio.charset.Charset;import java.nio.charset.CharsetDecoder;import java.nio.charset.CharsetEncoder;  public class GFG {      public static void main(String[] args)    {          // Gets charset        Charset Charset1 = Charset.forName("UTF16");          // Prints it        System.out.println(Charset1.name());    }}
UTF-16

Reference: https://docs.oracle.com/javase/9/docs/api/java/nio/charset/Charset.html#name–
Java-Charset
Java-Functions
Java-NIO package
Java
Java
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Constructors in Java
Exceptions in Java
Functional Interfaces in Java
Stream In Java
Different ways of Reading a text file in Java
Internal Working of HashMap in Java
Iterators in Java
Java Programming Examples
Comparator Interface in Java with Examples
Strings in Java
Program to find the kth factor of n using Python

Suppose we have two positive values n and k. Now consider we have a list of all factors of n sorted in ascending order, we have to find the kth factor in this list. If there are less than k factors, then return -1.
So, if the input is like n = 28 k = 4, then the output will be 7 because, the factors of 28 are [1,2,4,7,14,28], fourth one is 7.
To solve this, we will follow these steps −
if k is same as 1, thenreturn 1
if k is same as 1, then
return 1
return 1
cand := a list with one element [1]
cand := a list with one element [1]
for i in range 2 to 1 + floor of(square root of n), doif n mod i is same as 0, theninsert i at the end of candm := size of cand
for i in range 2 to 1 + floor of(square root of n), do
if n mod i is same as 0, theninsert i at the end of cand
if n mod i is same as 0, then
insert i at the end of cand
insert i at the end of cand
m := size of cand
m := size of cand
if k > 2*m or (k is same as 2*m and n = (last element of cand)^2)return -1
if k > 2*m or (k is same as 2*m and n = (last element of cand)^2)
return -1
return -1
if k <= m, thenreturn cand[k-1]
if k <= m, then
return cand[k-1]
return cand[k-1]
factor := cand[2*m - k]
factor := cand[2*m - k]
return quotient of n/factor
return quotient of n/factor
Let us see the following implementation to get better understanding −
from math import floor
def solve(n ,k):
   if k == 1:
      return 1
   cand = [1]
   for i in range(2, 1+floor(pow(n, 0.5))):
      if n%i == 0:
         cand.append(i)
      m = len(cand)
      if k > 2*m or (k == 2*m and n == cand[-1]**2):
         return -1
      if k <= m:
         return cand[k-1]
      factor = cand[2*m - k]
      return n//factor
n = 28
k = 4
print(solve(n ,k))
28, 4
7
SQL Query to Remove Primary Key - GeeksforGeeks

08 Oct, 2021
The primary key is the key that may contain one or more columns that uniquely identify each row in a table. We can add a primary key constraint while creating the and we can add or remove after by using ALTER command on our table of the database.
In this article let us see how we can remove a  primary key constraint in a table using MSSQL as the server.
Step 1: Creating a Database
We use the below command to create a database named GeeksforGeeks:
Query:
CREATE DATABASE GeeksforGeeks
Step 2: Using the Database
To use the GeeksforGeeks database use the below command:
Query:
USE GeeksforGeeks
Output:
Step 3: Creating the table
Create a table student_details with  3 columns using the following SQL query:  
Query:
CREATE TABLE student_details(
  stu_id VARCHAR(8) NOT NULL PRIMARY KEY,
  stu_name VARCHAR(20),
  stu_branch VARCHAR(20)
  );
Output:
Step 4: Verifying the database 
To view the description of the table using the following SQL query as follows.
Query:
EXEC sp_columns student_details
Output:
Step 5: Inserting data into the Table  
Inserting rows into student_details using the following SQL query:
Query:
INSERT INTO student_details VALUES
('1940001','PRATHAM','E.C.E'),
('1940002','ASHOK','C.S.E'),
('1940003','PAVAN KUMAR','C.S.E'),
('1940004','SANTHOSH','E.C.E'),
('1940005','THAMAN','E.C.E'),
('1940006','HARSH','E.E.E')
Output:
Step 6: Verifying the inserted data
Viewing the tables student_details,student_branch_details,student_address after inserting rows by using the following SQL query:
Query:
SELECT* FROM student_details 
Output:
Step 7: Knowing the constraints of the table using the following SQL query.
Query:
SELECT * FROM INFORMATION_SCHEMA.CONSTRAINT_COLUMN_USAGE  
Output:
Here in output ‘PK’ means primary key. The constraint can be known from the object explorer as well.
Step 8: Here we use the Drop constraint to remove the primary key from the database. DROP is used to delete a whole database or just a table. The DROP statement destroys the objects like an existing database, table, index, or view. A DROP statement in SQL removes a component from a relational database management system (RDBMS).
Query:
Removing the primary key constraint using the following query:
Query:
ALTER TABLE student_details
DROP CONSTRAINT PK__student___E53CAB21F07312DD
The primary key constraint is now removed:
Output:
Picked
SQL-Query
SQL-Server
SQL
SQL
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Update Multiple Columns in Single Update Statement in SQL?
How to Create a Table With Multiple Foreign Keys in SQL?
What is Temporary Table in SQL?
SQL | Subquery
SQL Query to Convert VARCHAR to INT
SQL Query to Find the Name of a Person Whose Name Starts with Specific Letter
SQL using Python
How to Write a SQL Query For a Specific Date Range and Date Time?
How to Select Data Between Two Dates and Times in SQL Server?
SQL Query to Compare Two Dates
How to create a multiline input control text area in HTML5 ? - GeeksforGeeks

06 Sep, 2021
The HTML <textarea> tag is used to specify a multiline input control text area in HTML5.  The <cols> and <rows> attributes specify size of a textarea.
Syntax
<textarea rows="" cols=""> Contents... </textarea>
The <textarea> tag contains 5 attributes that are listed below:
cols: It specifies width of textarea.
rows: It specifies height of textarea.
name: It holds the name to input control.
maxlength or minlength: It specifies the maximum or minimum number of characters in textarea.
placeholder: It specifies the hint of the value of textarea.
Example 1:
In this example, we will set the rows, and cols attribute to create a multiline control input textarea.
HTML
<!DOCTYPE html><html> <body>    <h1 style="color:green;">        GeeksforGeeks    </h1>    <textarea rows="10" cols="20">        welcome to GeeksforGeeks Aman Rathod.        A perfect Portal for Geeks    </textarea></body> </html>
Output:
Example 2: In this example, we will set the number of characters allowed in the input textarea.
HTML
<!DOCTYPE html><html> <body>    <h1 style="color:green;">      GeeksforGeeks    </h1>    <textarea minlenght="100" maxlength="300"        placeholder="Give Feedback here">    </textarea></body> </html>
Output: 
 
Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML  course.
varshagumber28
CSS-Properties
HTML-Attributes
HTML-Questions
HTML-Tags
Picked
HTML
Web Technologies
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to insert spaces/tabs in text using HTML/CSS?
Top 10 Projects For Beginners To Practice HTML and CSS Skills
How to update Node.js and NPM to next version ?
How to set the default value for an HTML <select> element ?
Hide or show elements in HTML using display property
Remove elements from a JavaScript Array
Installation of Node.js on Linux
Convert a string to an integer in JavaScript
How to fetch data from an API in ReactJS ?
How to insert spaces/tabs in text using HTML/CSS?
How to Extract and Copy Files from ISO Image in Linux? - GeeksforGeeks

20 Apr, 2021
The term ISO was derived from the ISO 9660 file system, which is commonly used by optical media. An ISO image is a full copy of everything contained on a physical optical disc, such as a CD, DVD, or Blu-ray disc, including the file system. There is no compression and they are a sector-by-sector copy of the disc. ISO images are designed to allow you to save an exact digital copy of a disc and then use that image to burn a new disc that is an exact copy of the original. Most operating systems (and many utilities) allow you to install an ISO image as a virtual disc, which means that all of your apps can treat it as if it were a real optical disc.
In certain cases, you can need to extract a single file or multiple files from an ISO image. Here we are going to see how to extract and Copy Files from ISO Image in Linux
The loop system can be used to mount ISO files. The mount command is needed. First, make a directory using the mkdir command:
$ mkdir /mnt/iso
Making directory
Now mount the iso image in a newly created directory using the below command:
$ mount -o loop isofilename.iso /mnt/iso
Mount iso to the directory
Change the directory to /mnt/iso:
Change directory
You can verify the content of iso using the ls command:
$ ls
Verifying content
You can now copy files to the /tmp directory easily:
Copying files
7-Zip is a free and open-source file archive, a program that compresses files and stores them in compact containers called “archives.”
First, install 7zip using the below command:
$ sudo apt-get install p7zip-full
Installing 7zip
Now you can extract the iso file using the below command:
$ sudo 7z x ubuntu-20.04.2.0-desktop-amd64.iso
Extracting iso file
Now you can copy files from extracted iso using the above steps.
You can also extract the archive using inbuilt GNOME manager just follow the below steps:
First, find your iso file where it is located:
Locate your file
Then right-click on it, and you will see the options menu:
Right-click on it
Now click on the extract here option in the options menu:
Extract file
Now you should see extracting pop-up wait till it finishes:
Wait till it finishes
After successful extract you can see your file by clicking show files:
You can view your files by clicking show files
Now you can copy any file you want by clicking right-click:
Copy files
In this article, we show you how to extract ISO files using 3 different easiest methods. That said, we appreciate your sticking with us to the end, and we hope the guide was as useful as we hoped.
Picked
How To
Linux-Unix
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install FFmpeg on Windows?
How to Add External JAR File to an IntelliJ IDEA Project?
How to Set Git Username and Password in GitBash?
How to create a nested RecyclerView in Android
How to Install Jupyter Notebook on MacOS?
Sed Command in Linux/Unix with examples
AWK command in Unix/Linux with examples
grep command in Unix/Linux
cut command in Linux with examples
cp command in Linux with examples
MoviePy – Adding Mask to Video File Clip

30 Aug, 2020
In this article we will see how we can add mask to the video file clip in MoviePy. MoviePy is a Python module for video editing, which can be used for basic operations on videos and GIF’s. IsMask property tells that if the given video clip is mask or not, mask is basically that video which is used as mask for the another video. We can make a video clip as mask with the help of set_ismask method. Adding mask gives copy of the clip with a completely opaque mask (made of ones). This makes computations slower compared to having a None mask but can be useful in many cases.
In order to do this we will use add_mask method with the VideoFileClip object
Syntax : clip.add_mask()
Argument : It takes no argument
Return : It returns VideoFileClip object
Below is the implementation
# Import everything needed to edit video clips from moviepy.editor import *    # loading video dsa gfg intro video clip = VideoFileClip("dsa_geek.mp4")      # getting only first 5 secondsclip = clip.subclip(0, 5)  # add mask to the clipclip = clip.add_mask()    # displaying new clipclip.ipython_display(width = 420)
Output :
Clip is Mask  : False
Moviepy - Building video __temp__.mp4.
Moviepy - Writing video __temp__.mp4

                                                                                                                       
Moviepy - Done !
Moviepy - video ready __temp__.mp4

Another example
# Import everything needed to edit video clipsfrom moviepy.editor import *  # loading video gfgclip = VideoFileClip("geeks.mp4")    # getting only first 5 secondsclip = clip.subclip(0, 5)  # add mask to the clipclip = clip.add_mask()    # displaying new clipclip.ipython_display(width = 420)
Output :
Clip is Mask  : True
Moviepy - Building video __temp__.mp4.
MoviePy - Writing audio in __temp__TEMP_MPY_wvf_snd.mp3
                                                                                                                       
MoviePy - Done.
Moviepy - Writing video __temp__.mp4

                                                                                                                       
Moviepy - Done !
Moviepy - video ready __temp__.mp4

Python-MoviePy
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
Different ways to create Pandas Dataframe
Enumerate() in Python
Read a file line by line in Python
Python String | replace()
How to Install PIP on Windows ?
*args and **kwargs in Python
Python Classes and Objects
Iterate over a list in Python
Python OOPs Concepts
Python – Add prefix to each key name in dictionary

01 Aug, 2020
Given a dictionary, update its each key by adding prefix to each key.
Input : test_dict = {‘Gfg’ : 6, ‘is’ : 7, ‘best’ : 9}, temp = “Pro”Output : {‘ProGfg’ : 6, ‘Prois’ : 7, ‘Probest’ : 9}Explanation : “Pro” prefix added to each key.
Input : test_dict = {‘Gfg’ : 6, ‘is’ : 7, ‘best’ : 9}, temp = “a”Output : {‘aGfg’ : 6, ‘ais’ : 7, ‘abest’ : 9}Explanation : “a” prefix added to each key.
Method #1 : Using dictionary comprehension
This is one of the methods in which this task can be performed. In this we construct new dictionary by performing concatenation of prefix with all keys.
Python3
# Python3 code to demonstrate working of # Add prefix to each key name in dictionary# Using loop  # initializing dictionarytest_dict = {'Gfg' : 6, 'is' : 7, 'best' : 9, 'for' : 8, 'geeks' : 11}   # printing original dictionaryprint("The original dictionary is : " + str(test_dict))  # initializing prefix temp = "Pro"  # + operator is used to perform task of concatenationres = {temp + str(key): val for key, val in test_dict.items()}  # printing result print("The extracted dictionary : " + str(res)) 
The original dictionary is : {'Gfg': 6, 'is': 7, 'best': 9, 'for': 8, 'geeks': 11}
The extracted dictionary : {'ProGfg': 6, 'Prois': 7, 'Probest': 9, 'Profor': 8, 'Progeeks': 11}

Method #2 : Using f strings + dictionary comprehension
The combination of above functionalities can be used to solve this problem. In this, we perform the task of concatenation using f strings. Works only in >=3.6 versions of Python.
Python3
# Python3 code to demonstrate working of # Add prefix to each key name in dictionary# Using f strings + dictionary comprehension  # initializing dictionarytest_dict = {'Gfg' : 6, 'is' : 7, 'best' : 9, 'for' : 8, 'geeks' : 11}   # printing original dictionaryprint("The original dictionary is : " + str(test_dict))  # initializing prefix temp = "Pro"  # dictionary comprehension is used to bind result # f strings are used to bind prefix with keyres = {f"Pro{key}": val for key, val in test_dict.items()}  # printing result print("The extracted dictionary : " + str(res)) 
The original dictionary is : {'Gfg': 6, 'is': 7, 'best': 9, 'for': 8, 'geeks': 11}
The extracted dictionary : {'ProGfg': 6, 'Prois': 7, 'Probest': 9, 'Profor': 8, 'Progeeks': 11}

Python dictionary-programs
Python
Python Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
Python Classes and Objects
Python | os.path.join() method
Introduction To PYTHON
Python OOPs Concepts
Defaultdict in Python
Python | Get dictionary keys as a list
Python | Convert a list to dictionary
Python | Convert string dictionary to dictionary
Python Program for Fibonacci numbers
Python | Intersection in Tuple Records Data

29 Oct, 2019
Sometimes, while working with data, we may have a problem in which we require to find the matching records between two lists that we receive. This is a very common problem and records usually occur as a tuple. Let’s discuss certain ways in which this problem can be solved.
Method #1 : Using list comprehensionList comprehension can opt as method to perform this task in one line rather than running a loop to find the common element. In this, we just iterate for single list and check if any element occurs in other one.
# Python3 code to demonstrate working of# Intersection in Tuple Records Data# Using list comprehension  # Initializing liststest_list1 = [('gfg', 1), ('is', 2), ('best', 3)]test_list2 = [('i', 3), ('love', 4), ('gfg', 1)]  # printing original listsprint("The original list 1 is : " + str(test_list1))print("The original list 2 is : " + str(test_list2))  # Intersection in Tuple Records Data# Using list comprehensionres = [ele1 for ele1 in test_list1        for ele2 in test_list2 if ele1 == ele2]  # printing resultprint("The Intersection of data records is : " + str(res))
The original list 1 is : [('gfg', 1), ('is', 2), ('best', 3)]
The original list 2 is : [('i', 3), ('love', 4), ('gfg', 1)]
The Intersection of data records is : [('gfg', 1)]

 
Method #2 : Using set.intersection()This task can also be performed in smaller way using the generic set intersection. In this, we first convert the list of records to a set and then perform its intersection using intersection().
# Python3 code to demonstrate working of# Intersection in Tuple Records Data# Using set.intersection()  # Initializing liststest_list1 = [('gfg', 1), ('is', 2), ('best', 3)]test_list2 = [('i', 3), ('love', 4), ('gfg', 1)]  # printing original listsprint("The original list 1 is : " + str(test_list1))print("The original list 2 is : " + str(test_list2))  # Intersection in Tuple Records Data# set.intersection()res = list(set(test_list1).intersection(set(test_list2)))  # printing resultprint("The Intersection of data records is : " + str(res))
The original list 1 is : [('gfg', 1), ('is', 2), ('best', 3)]
The original list 2 is : [('i', 3), ('love', 4), ('gfg', 1)]
The Intersection of data records is : [('gfg', 1)]

Python list-programs
Python tuple-programs
Python
Python Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
Different ways to create Pandas Dataframe
Enumerate() in Python
Read a file line by line in Python
Python String | replace()
Python program to convert a list to string
Defaultdict in Python
Python | Get dictionary keys as a list
Python | Convert a list to dictionary
Python | Convert string dictionary to dictionary
Python – Counter.items(), Counter.keys() and Counter.values()

27 Oct, 2021
Counter class is a special type of object data-set provided with the collections module in Python3. Collections module provides the user with specialized container datatypes, thus, providing an alternative to Python’s general-purpose built-ins like dictionaries, lists and tuples. Counter is a sub-class that is used to count hashable objects. It implicitly creates a hash table of an iterable when invoked. 
The Counter.items() method helps to see the elements of the list along with their respective frequencies in a tuple.  
Syntax : Counter.items()Parameters : NoneReturns : object of class dict_items  
Example :  
Python3
# importing the modulefrom collections import Counter # making a listlist = [1, 1, 2, 3, 4, 5,        6, 7, 9, 2, 3, 4, 8] # instantiating a Counter objectob = Counter(list) # Counter.items()items = ob.items() print("The datatype is "      + str(type(items))) # displaying the dict_itemsprint(items) # iterating over the dict_itemsfor i in items:    print(i)
Output :  
The datatype is dict_items([(1, 2), (2, 2), (3, 2), (4, 2), (5, 1), (6, 1), (7, 1), (9, 1), (8, 1)]) (1, 2) (2, 2) (3, 2) (4, 2) (5, 1) (6, 1) (7, 1) (9, 1) (8, 1)  
 
The Counter.keys() method helps to see the unique elements in the list. 
Syntax : Counter.keys()Parameters : NoneReturns : object of class dict_items  
Example :  
Python3
# importing the modulefrom collections import Counter # making a listlist = [1, 1, 2, 3, 4, 5,        6, 7, 9, 2, 3, 4, 8] # instantiating a Counter objectob = Counter(list) # Counter.keys()keys = ob.keys() print("The datatype is "      + str(type(keys))) # displaying the dict_itemsprint(keys) # iterating over the dict_itemsfor i in keys:    print(i)
Output :  
The datatype is dict_keys([1, 2, 3, 4, 5, 6, 7, 9, 8]) 1 2 3 4 5 6 7 9 8  
 
The Counter.values() method helps to see the frequencies of each unique element.  
Syntax : Counter.values()Parameters : NoneReturns : object of class dict_items  
Example :  
Python3
# importing the modulefrom collections import Counter # making a listlist = [1, 1, 2, 3, 4, 5,        6, 7, 9, 2, 3, 4, 8] # instantiating a Counter objectob = Counter(list) # Counter.values()values = ob.values() print("The datatype is "      + str(type(values))) # displaying the dict_itemsprint(values) # iterating over the dict_itemsfor i in values:    print(i)
Output :  
The datatype is dict_values([2, 2, 2, 2, 1, 1, 1, 1, 1]) 2 2 2 2 1 1 1 1 1  
 
anikaseth98
Python collections-module
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Matplotlib.pyplot.xkcd() in Python

24 Feb, 2022
One of the main process in Data Science is Data Visualization. Data Visualization refers to present a dataset in the form of graphs and pictures. We can identify upcoming trend by observing these Graphs.
Python provides us with an amazing Data Visualization library in it which is Matplotlib which was developed by John Hunter (1968-2012). Matplotlib is built on numpy and sideby framework that’s why it is fast and efficient. It is open-source and has huge community support.It possesses the ability to work well with many operating systems and graphic backends. 
Generally, plots generated by matplotlib are very perfect as well as monotonous. Observing these graphs are not that much fun. Matplotlib provides a library that can make these graphs a bit interesting and draws graphs in comic style. These graphs are interesting and everyone would love to study through these graphs. 
For Example :  
Parameters :All three parameters in xkcd() are optional. 
Example 1: 
Lets generate a sine wave in xkcd() style  
Python3
import numpy as npimport matplotlib.pyplot as plt time = np.arange(0, 10, 0.1);amplitude = np.sin(time) with plt.xkcd():    plt.plot(time, amplitude)    plt.title('Sine wave')    plt.xlabel('Time')    plt.ylabel('Amplitude = sin(time)')    plt.axhline(y = 0, color ='k')         plt.show()
Output : 
Example 2:
Python3
import numpy as npimport matplotlib.pyplot as plt  with plt.xkcd():    plt.plot([1, 2, 3, 4], [5, 4, 9, 2])    plt.title('matplotlib.pyplot.xkcd()')    plt.axhline(y = 0, color ='k')         plt.show()
Output:
 
surinderdawra388
kapoorsagar226
varshagumber28
Python-matplotlib
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
Python Classes and Objects
Python | os.path.join() method
Introduction To PYTHON
Python OOPs Concepts
How to drop one or multiple columns in Pandas Dataframe
How To Convert Python Dictionary To JSON?
Check if element exists in list in Python
Python | Get unique values from a list
Create a directory in Python
Remove elements from array using JavaScript filter - JavaScript

Suppose, we have two arrays of literals like these −
const arr1 = [4, 23, 7, 6, 3, 6, 4, 3, 56, 4];
const arr2 = [4, 56, 23];
We are required to write a JavaScript function that takes in these two arrays and filters the first to contain only those elements that are not present in the second array.
And then return the filtered array to get the below output −
const output = [7, 6, 3, 6, 3];
Following is the code −
const arr1 = [4, 23, 7, 6, 3, 6, 4, 3, 56, 4];
const arr2 = [4, 56, 23];
const filterArray = (arr1, arr2) => {
   const filtered = arr1.filter(el => {
      return arr2.indexOf(el) === -1;
   });
   return filtered;
};
console.log(filterArray(arr1, arr2));
This will produce the following output in console −
[ 7, 6, 3, 6, 3 ]
Introduction to Dask in Python

10 Jul, 2020
Dask is a library that supports parallel computing in python. It provides features like-
Dynamic task scheduling which is optimized for interactive computational workloadsBig data collections of dask extends the common interfaces like NumPy, Pandas etc.
Dynamic task scheduling which is optimized for interactive computational workloads
Big data collections of dask extends the common interfaces like NumPy, Pandas etc.
Most of the BigData analytics will be using Pandas, NumPy for analyzing big data. All the mentioned packages support a wide variety of computations. But when the dataset doesn’t fit in the memory these packages will not scale. Here comes dask. When the dataset doesn’t “fit in memory” dask extends the dataset to “fit into disk”. Dask allows us to easily scale out to clusters or scale down to single machine based on the size of the dataset. 
To install this module type the below command in the terminal – 
python -m pip install "dask[complete]" 
Let’s see an example comparing dask and pandas. To download the dataset used in the below examples, click here.
1. Pandas Performance: Read the dataset using pd.read_csv()
Python3
import pandas as pd  %time temp = pd.read_csv('dataset.csv',                          encoding = 'ISO-8859-1')
Output:
CPU times: user 619 ms, sys: 73.6 ms, total: 692 ms
Wall time: 705 ms
2. Dask Performance: Read the dataset using dask.dataframe.read_csv
Python3
import dask.dataframe as dd  %time df = dd.read_csv("dataset.csv",                         encoding = 'ISO-8859-1')
Output:
CPU times: user 21.7 ms, sys: 938 μs, total: 22.7 ms
Wall time: 23.2 ms
Now a question might arise that how large datasets were handled using pandas before dask? There are few tricks handled to manage large datasets in pandas.
Using chunksize parameter of read_csv in pandasUse only needed columns while reading the csv files
Using chunksize parameter of read_csv in pandas
Use only needed columns while reading the csv files
The above techniques will be followed in most cases while reading large datasets using pandas. But in some cases, the above might not be useful at that time dask comes into play a major role.
There are certain limitations in dask.
Dask cannot parallelize within individual tasks.As a distributed-computing framework, dask enables remote execution of arbitrary code. So dask workers should be hosted within trusted network only.
Dask cannot parallelize within individual tasks.
As a distributed-computing framework, dask enables remote execution of arbitrary code. So dask workers should be hosted within trusted network only.
python-modules
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
Different ways to create Pandas Dataframe
Enumerate() in Python
Python String | replace()
How to Install PIP on Windows ?
*args and **kwargs in Python
Python Classes and Objects
Iterate over a list in Python
Convert integer to string in Python
Python OOPs Concepts