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!