Import and Export csv files
In work, you need to import csv file data to the database or export the database data as a csv file. The following is my simple implementation.
1
For example, if the website is an e-commerce shopping website, you need to perform the batch import function to operate and store all the fields in the database in the table, then, the program reads the value values in the table and inserts them into the corresponding table. Is there any similar function provided by a great God? Example
A website is an e-commerce shopping website. The batch import function
Export Examples:Select *from Testinto outfile ' d:test.csv 'Fields terminated by ', ' optionally-enclosed by ' "' escaped by '" 'Lines terminated by ' \ r \ n ';Import Example:Load data infile ' D:test.csv 'into table ' test 'Fields terminated by ', ' optionally-enclosed by ' "' escaped by '" 'Lines terminated by ' \ n ' ignore 1 lines;The actual operation in accordance with this modification on the line, the problem of the place also hope to teach ~
Mysql imports the csv file bitsCN.com
Mysql imports csv files
The mysql load data infile command can import DATA from the csv flat file to the database.
In linux:
Load data infile '/home/test/dump/ip_location.csv 'into TABLE ip_location character set utf8 fields terminated by', 'enabledby' "'; -- charact
MySQL imports and exports CSV files bitsCN.com
MySQL provides a tool for importing and exporting databases. However, sometimes we only need to import and export data from a single table, such as importing and exporting CSV files. in this case, you can use the MySQL automatic command to import and export data.
The e
This article mainly introduces the PHP programming implementation of the CSV file import MySQL database method, involving PHP file reading, conversion, database connection, insert and other related operations skills, the need for friends can refer to the next
Specific as follows:
config.db.php content is as follows;
index.php content is as follows:
insertdb.php content is as follows:
The above
Sometimes write a program when the background requirements to import large amounts of data into the database, such as computer test results of the query, phone book data, etc. are generally stored in Excel, then we can export data into a CSV file, and then through the following procedures can be in the background batch import data into the database.
The following
Sometimes write a program when the background requirements to import large amounts of data into the database, such as computer test results of the query, phone book data, etc. are generally stored in Excel, then we can export data into a CSV file, and then through the following procedures can be in the background batch import data into the database.
The following
Sometimes write a program when the background requirements to import a large number of data into the database, such as computer test results of the query, phone book data are generally stored in Excel, when we can export data into a CSV file, and then through the following program can be in the background batch import data into the database.
The following are jus
There are more than 500 CSV files. To import SQL databases, the database fields are the same as the file fields,
How to Write batch import statements.
Declare @ dir sysname, @ cmd nvarchar (max );Set @ dir = 'C :/';
Create Table # TMP (filename nvarchar (1024 ));Set @ cmd = n' dir "'+ @ dir +' *. CSV"/B'Insert # TMP e
This code is used to import and export DataTable files in xml, excel, and csv files. Record the code for future use.
Be sure to import the excel file and add a reference to Microsoft. Office. Interop. Excel 11.0.
Default. aspx. cs File
Using System;Using System. Collections. Generic;Using System. Linq;Using System. Web;Using System. Web. UI;Using System. Web. UI.
Sometimes, when writing a program, the background requires that a large amount of data be imported into the database. For example, the computer examination result query and phone book data are generally stored in excel, in this case, we can export the data to a csv file, and then use the following program to import data to the database in batches in the background.
The following are the main program parts:
MySQL provides a tool for importing and exporting databases. However, sometimes we only need to import and export data from a single table, such as importing and exporting CSV files. In this case, you can use the MySQL Automatic Command to import and export data.
The export syntax is as follows:
SELECT * FROM [TABLE]
Into outfile '[FILE]';
Or
SELECT * FROM [TAB
The examples in this article describe the import and export classes of PHP implementation CSV files. Share to everyone for your reference. as follows:
I hope this article will help you with your PHP programming.
CVS file import mysql database command:
The code is as follows
Copy Code
Set names UTF8;LOAD DATA local INFILE ' c:\\resource.csv 'into TABLE ResourceFIELDS terminated by ""LINES terminated by ' \ r \ n '(Title,singer);
FIELDS terminated by----field terminating characterOptionally enclosed by----envelope characterLINES terminated by----line terminator
Export data for a period of time to CVS:
code i
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.