How to deal with uploading CSV file content to the database-php Tutorial

Source: Internet
Author: User
The CSV file content is uploaded to the database. I have a lot of CSV format data to be uploaded to MYSQL, but there are more than 20 rows in front of it. useless data. how can I delete the previous data and upload the remaining useful data, could you please give me a thought or CODE? ---------- What should I do if CSV of different structures is used? Are there ready-made classes? For example, a.csv1_1%2%3123b.csv namesexage CSV file content is uploaded to the database.
I have a lot of CSV data to upload to MYSQL

However, there are more than 20 rows of useless data. how can I delete the previous data and upload the remaining useful data? could you please give me some ideas or CODE?

----------
What should I do if CSV files of different structures are used? Are there ready-made classes?
For example:
A.csv

Title 1 title 2 title 3
1 2 3


B .csv

Name sex age
.......

====================================

I am a newbie. thank you for your help!



------ Solution --------------------
This is an example. For more information, see:
PHP code
$ Arr = file ("aa.csv" );file_put_contents('aa.csv ', join ("", array_slice ($ arr, 20); mysql_connect ('localhost', "root ",''); $ SQL = "load data infile 'absolute path/aa.csv 'into table test.csv fields terminated by', '"; // database name: test, table name: csvmysql_query ($ SQL) or die (mysql_error ());
------ Solution --------------------
Discussion

I mean, can I delete the first N rows of data in PHP. Please advise!

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.