How can we export some field(s) from MySQL table into a text file?

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

627 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

How can we import the text file, having some line prefixes, into MySQL table?

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

163 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

How can we MySQL LOAD DATA INFILE statement with ‘ENCLOSED BY’ option to import data from text file into MySQL table?

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

684 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

How can we transfer information between MySQL and data files?

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

75 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 C#

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

144 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

Clone() method in C#

karthikeya Boyini
Updated on 20-Jun-2020 09:12:10

581 Views

The Clone() method in C# is used to create a similar copy of the array.Let us see an example to clone an array using the Clone() method −Example Live Demousing System; class Program {    static void Main() {       string[] arr = { "one", "two", "three", "four", "five" };       string[] arrCloned = arr.Clone() as string[];       Console.WriteLine(string.Join(", ", arr));       // cloned array       Console.WriteLine(string.Join(", ", arrCloned));       Console.WriteLine();    } }Outputone, two, three, four, five one, two, three, four, fiveAbove, we have a string array −string[] ... Read More

Write a C# program to check if a number is Palindrome or not

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

785 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 all duplicates from a given string in Python

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

384 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

How can we store a value in user-defined variable?

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

181 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

Map function and Dictionary in Python to sum ASCII values

karthikeya Boyini
Updated on 20-Jun-2020 09:09:09

576 Views

We want to calculate the ASCII sum for each word in a sentence and the sentence as a whole using map function and dictionaries. For example, if we have the sentence −"hi people of the world"The corresponding ASCII sums for the words would be : 209 645 213 321 552And their total would be : 1940.We can use the map function to find the ASCII value of each letter in a word using the ord function. Then using the sum function we can sum it up. For each word, we can repeat this process and get a final sum of ... Read More

Advertisements