CSV文件内容上传数据库,该怎么处理
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>

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

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

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

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 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...

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.

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...

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 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
