top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

How can I load data from a text file into a table?

+1 vote
674 views
How can I load data from a text file into a table?
posted May 27, 2014 by Karamjeet Singh

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

3 Answers

+1 vote

Hi

If you are referring to mysql table then you can use the LOAD INFILE sql command for loading data to table.

The data in text file can be in a csv format which is basically a comma separate format where each field in the record is separated by a comma.

answer May 28, 2014 by Shyam Purkayastha
0 votes

LOAD DATA INFILE file_name;
Using this Syntax ,Data can be loaded from a text file.
But for loading data correctly, 1) you need to delimit your data 2) Columns and data should be matched properly.

answer May 28, 2014 by Rahul Mahajan
0 votes

To load the text file pet.txt into the pet table, use this statement:

mysql> LOAD DATA LOCAL INFILE '/path/datanew.txt' INTO TABLE datanew;

answer May 30, 2014 by Vrije Mani Upadhyay
Similar Questions
+1 vote

I have to load the target table copy of data into the text file at the time of workflow running.(i.e)Whatever data are going into the the target table that should come into the text file also.

0 votes
for($i=0;$i<=feof($getdata);$i++)
{
if (filter_var($data[$i][1], FILTER_VALIDATE_EMAIL)){
echo $data[$i][1];
$email=$data[$i][1];
$conn = mysqli_connect($dbhost,$dbuser,$dbpass, $dbname);
if ($conn->connect_error) {
  die("Connection failed: " . $conn->connect_error);
}
$sql ="INSERT INTO promo_user (uid,name,email) VALUES (,'', '$email')";
mysqli_query($sql,$conn);
mysqli_close($conn);

I am using the above code but there is something wrong with it,whenever i run the code the echo is working fine but the content does go into sql table

Please help

0 votes

How can I insert data into one table from two other tables where i have three tables namely users, role and userrole.
Now I want to insert the data into userrole table from users table and role table with a single statement.

0 votes

Design a mapping to load the first record from a flat file into one table A, the last record from a flat file into table B and the remaining records into table C?

...