mysql adminer 导入csv,从CSV导入MySql

I have a table with three columns, NODEID, X, Y. NODEID is the primary key and it is set as an INT(4) to be AUTOINCREMENT. I wish to add more data to this table by importing it from a CSV via the phpmyadmin import. Question:

What would be the format of the CSV look like?

Is this possible or is importing basically just to replace the whole data with the CSV?

As of now the CSV looks like:

1,-105.057578,39.785603

2,-105.038646,39.771132

3,-105.013045,39.771727

5,-105.045721,39.762055

6,-105.031777,39.76206

7,-105.046015,39.72835

8,-105.029796,39.728304

10,-104.930863,39.754579

11,-104.910624,39.754644

13,-104.930959,39.74367

16,-105.045802,39.685253

17,-105.032149,39.688557

18,-105.060891,39.657622

20,-105.042257,39.644086

etc...

解决方案

Change the SQL that phpmyadmin will run to this:

LOAD DATA INFILE '*FILEPATH*'

INTO TABLE *table*

(X, Y);

(You will only have to change the last line)

And your csv should look like

-105.057578,39.785603

-105.038646,39.771132

-105.013045,39.771727

-105.045721,39.762055

-105.031777,39.76206

-105.046015,39.72835

The last line tells MySQL to look for only those two columns of data and insert null for any other columns. The NULL value will be auto-incremented as expected.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值