Home Backend Development PHP Tutorial CSV文件内容上传数据库,该怎么处理

CSV文件内容上传数据库,该怎么处理

Jun 13, 2016 pm 01:32 PM
csv file mysql quot test

CSV文件内容上传数据库
我有许多CSV格式的数据需要上传到MYSQL

但是前面大概20多行,无用数据,如何删除前面的数据,把剩下有用的上传,请各位大侠帮忙给个 思路或者CODE?

----------
如果不同结构的CSV该如何处理?有现成的类吗?
比如:
a.csv

标题1 标题2 标题3
1 2 3


b.csv

name sex age
.. .. ...

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

本人菜鸟,谢谢大家帮忙!



------解决方案--------------------
这是一个例子,你可以参考一下:

PHP code
$arr=file("aa.csv");
file_put_contents('aa.csv',join("",array_slice($arr,20)));

mysql_connect('localhost',"root",'');
$sql="load data infile '绝对路径/aa.csv' into table test.csv fields terminated by ','";  //库名:test,表名:csv
mysql_query($sql) or die(mysql_error());
<br><font color="#e78608">------解决方案--------------------</font><br>
Copy after login
探讨

我的意思是能不能PHP删除前面N行数据。请指点!
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
Two Point Museum: All Exhibits And Where To Find Them
1 months ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to fix mysql_native_password not loaded errors on MySQL 8.4 How to fix mysql_native_password not loaded errors on MySQL 8.4 Dec 09, 2024 am 11:42 AM

One of the major changes introduced in MySQL 8.4 (the latest LTS release as of 2024) is that the &quot;MySQL Native Password&quot; plugin is no longer enabled by default. Further, MySQL 9.0 removes this plugin completely. This change affects PHP and other app

Huawei Watch GT 5 smartwatch gets update with new features Huawei Watch GT 5 smartwatch gets update with new features Oct 03, 2024 am 06:25 AM

Huawei is rolling out software version 5.0.0.100(C00M01) for the Watch GT 5 and the Watch GT 5 Prosmartwatchesglobally. These two smartwatches recently launched in Europe, with the standard model arriving as the company’s cheapest model. This Harmony

New Xiaomi Mijia Graphene Oil Heater with HyperOS arrives New Xiaomi Mijia Graphene Oil Heater with HyperOS arrives Oct 02, 2024 pm 09:02 PM

Xiaomi will shortly launch the Mijia Graphene Oil Heater in China. The company recently ran a successful crowdfunding campaign for the smart home product, hosted on its Youpin platform. According to the page, the device has already started to ship to

The page is blank after PHP is connected to MySQL. What is the reason for the invalid die() function? The page is blank after PHP is connected to MySQL. What is the reason for the invalid die() function? Apr 01, 2025 pm 03:03 PM

The page is blank after PHP connects to MySQL, and the reason why die() function fails. When learning the connection between PHP and MySQL database, you often encounter some confusing things...

Monitoring Redis Droplets Using Redis Exporter Service Monitoring Redis Droplets Using Redis Exporter Service Jan 06, 2025 am 10:19 AM

Effective monitoring of Redis databases is essential for maintaining optimal performance, identifying potential bottlenecks, and ensuring overall system reliability. Redis Exporter Service is a robust utility designed to monitor Redis databases using Prometheus. This tutorial will guide you through the complete setup and configuration of Redis Exporter Service, ensuring you establish a monitoring solution seamlessly. By following this tutorial, you’ll achieve a fully operational monitoring setup to effectively monitor the performance metrics of your Redis database.

How to efficiently integrate Node.js or Python services under LAMP architecture? How to efficiently integrate Node.js or Python services under LAMP architecture? Apr 01, 2025 pm 02:48 PM

Many website developers face the problem of integrating Node.js or Python services under the LAMP architecture: the existing LAMP (Linux Apache MySQL PHP) architecture website needs...

PHP optimistic locking combined with transaction deduction balance failed: How to ensure that the balance is correctly deducted in concurrency situations? PHP optimistic locking combined with transaction deduction balance failed: How to ensure that the balance is correctly deducted in concurrency situations? Mar 31, 2025 pm 11:42 PM

Detailed explanation of the problem of deducting balances in combination with PHP optimistic locks and transactions in this article will analyze in detail a balance deduction using PHP, optimistic locks and database transactions, only...

SenseRobot unveils AI chess robot with 2,900 ELO to help children hone tactics on real chess boards SenseRobot unveils AI chess robot with 2,900 ELO to help children hone tactics on real chess boards Oct 03, 2024 am 06:34 AM

SenseRobot has unveiled the SenseRobot Chess - an AI robotic chess coach to help children hone their chess tactics. The robot can be set to 25 ELO difficulty levels from 200 to 2,900, allowing beginners and grandmasters to challenge themselves with a

See all articles