Export Fields from MySQL Table to Text File

Abhinanda Shri
Updated on 20-Jun-2020 09:23:46

936 Views

It can be done by providing the column(s) names in the SELECT … INTO OUTFILE statement while exporting the data from MySQL table into a file. We are illustrating it with the help of the following example −ExampleSuppose we are having following data from table ‘Student_info’ −mysql> Select * from Student_info; +------+---------+------------+------------+ | id   | Name    | Address    | Subject    | +------+---------+------------+------------+ | 101  | YashPal | Amritsar   | History    | | 105  | Gaurav  | Chandigarh | Literature | | 125  | Raman   | Shimla     | Computers  | | 130 ... Read More

Import Text File with Line Prefixes into MySQL Table

usharani
Updated on 20-Jun-2020 09:17:27

257 Views

Suppose if we have a line prefix in the text file then with the help of using ‘LINES STARTING BY’ option we can ignore that prefix and import correct data into MySQL table. It can be understood with the help of the following example −ExampleSuppose we are using ‘VALUE’ as the ‘LINE PREFIX’ in the text file as follows −id,         Name,     Country,        Salary VALUE:105,  Chum*,    Marsh, USA,      11000 106,        Danny*,   Harrison, AUS,   12000Now while importing this text file into MySQL table then we ... Read More

MySQL LOAD DATA INFILE with ENCLOSED BY Option

seetha
Updated on 20-Jun-2020 09:15:29

964 Views

Sometimes the input text files have the text fields enclosed by double quotes and to import data from such kind of files we need to use the ‘ENCLOSED BY’ option with LOAD DATA INFILE statement. We are considering the following example to make it understand −ExampleFollowings are the comma-separated values in A.txt file −100, ”Ram”, ”INDIA”, 25000 101, ”Mohan”, ”INDIA”, 28000We want to import this data into the following file named employee2_tbl −mysql> Create table employee2_tbl(Id Int, Name Varchar(20), Country Varchar(20), Salary Int); Query OK, 0 rows affected (0.1 sec)Now, the transfer of data from a file to a ... Read More

Transfer Information Between MySQL and Data Files

mkotla
Updated on 20-Jun-2020 09:14:18

171 Views

Transferring the information between MySQL and data files mean importing data from data files into our database or exporting data from our database into files. MySQL is having two statements that can be used to import or export data between MySQL and data files −LOAD DATA INFILEThis statement is used for importing the data from data files into our database. It reads data records directly from a file and inserts them into a table. Its syntax would be as follows −SyntaxLOAD DATA LOCAL INFILE '[path/][file_name]' INTO TABLE [table_name ];Here, the path is the address of the file.file_name is the name ... Read More

Comments in Chash

Samual Sam
Updated on 20-Jun-2020 09:13:35

294 Views

Comments are used for explaining the code. Compilers ignore the comment entries. The multiline comments in C# programs start with /* and terminate with the characters */ as shown below.Multi-line comments/* The following is a multi-line comment In C# /*The /*...*/ is ignored by the compiler and it is put to add comments in the program.Single line comments// variable int a = 10;The following is a sample C# program showing how to add single-line as well as multi-line comments −Example Live Demousing System; namespace HelloWorldApplication {    class HelloWorld {       static void Main(string[] args) {     ... Read More

Check If a Number is Palindrome in C#

Samual Sam
Updated on 20-Jun-2020 09:11:43

1K+ Views

First, find the reverse of the string to check if a string is a palindrome or not −Array.reverse()Now use the equals() method to match the original string with the reversed. If the result is true, that would mean the string is Palindrome.Let us try the complete example. Here, our string is “Madam”, which is when reversed gives the same result −Example Live Demousing System; namespace Demo {    class Program {       static void Main(string[] args) {          string string1, rev;          string1 = "Madam";          char[] ch = string1.ToCharArray(); ... Read More

Remove Duplicates from a String in Python

Samual Sam
Updated on 20-Jun-2020 09:10:40

774 Views

To remove all duplicates from a string in python, we need to first split the string by spaces so that we have each word in an array. Then there are multiple ways to remove duplicates.We can remove duplicates by first converting all words to lowercase, then sorting them and finally picking only the unique ones. For example, Examplesent = "Hi my name is John Doe John Doe is my name" # Seperate out each word words = sent.split(" ") # Convert all words to lowercase words = map(lambda x:x.lower(), words) # Sort the words in order words.sort() ... Read More

Store a Value in User-Defined Variable

Nitya Raut
Updated on 20-Jun-2020 09:09:22

302 Views

We can store a value in a user-defined variable in a statement and then refer to it afterward in other statements. Followings are the ways to store a value in user-defined variable −With SET statementwe can store a user-defined variable by issuing a SET statement as follows −SyntaxSET @var_name = expr[, @var_name = expr]…In this @var_name is the variable name which consists of alphanumeric characters from current character set. We can use either = or := assignment operator with SET statement.For example following queries can store the user variables with SET statement −mysql> SET @value = 500; Query OK, 0 ... Read More

MySQL EXPORT SET Function Output with Skipped Fifth Argument

Samual Sam
Updated on 20-Jun-2020 09:08:37

101 Views

Actually, the default value of the fifth argument i.e. number of bits is 64, hence if we will not specify any value on fifth argument them MySQL will check the bits up to 64 bits and produce the result. It can be understood from the following example −Examplemysql> SELECT EXPORT_SET(5, 'Y', 'N', ' ')\G *************************** 1. row *************************** EXPORT_SET(5, 'Y', 'N', ' '): Y N Y N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N ... Read More

Map Function and Lambda Expression in Python to Replace Characters

Samual Sam
Updated on 20-Jun-2020 09:08:20

674 Views

We want to replace a character a1 with a character a2 and a2 with a1. For example, For the input string, "puporials toinp"and characters p and t, we want the end string to look like −"tutorials point"For this we can use map function and lambdas to make the replacement. The map(lambda, input) function iterates over each item passed to it(in form of iterable input) and apply the lambda expression to it. So we can use it as follows −Example Live Demodef replaceUsingMapAndLambda(sent, a1, a2): # We create a lambda that only works if we input a1 or a2 and swaps them. ... Read More

Advertisements