2

How can I get rid of these null columns? I'm importing my csv file to create a table on phpMyAdmin. The sql query looks appropriate but at the end, I get...

`Category 1` VARCHAR( 97 ) ,
`Category 2` VARCHAR( 113 ) ,
`NULL` VARCHAR( 71 ) ,
`NULL` VARCHAR( 56 ) ,
`NULL` VARCHAR( 73 ) ,
`NULL` VARCHAR( 97 )
) ENGINE = MYISAM DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;

MySQL said: 

#1060 - Duplicate column name 'NULL'

Category 2 should be the last column. I can't figure out where the null columns are coming from, or how to get rid of them. The original file is given to me in .xls format. I make some changes and save as csv. I used to upload an xls file (never had problems) but I think our cPanel was upgraded so it's all changed.

So far I've tried deleting 4+ columns at the end while in OpenOffice. I've tried opening the csv in notepad and making sure there was no extra commas or spaces, adding in / to escape. I've tried fiddling with the import options in phpMyAdmin but I'm far from an expert so no luck there.

4

4 回答 4

3

对我来说,我必须选择:

用,分隔的列

用"括起来的列

列转义为

以auto终止的行

并检查文件的第一行包含表列名

于 2013-07-23T18:20:35.493 回答
1

遇到了这个问题,对我来说修复它的方法不是很直观。

在导入设置中,我检查了用[ " ]括起来的列。

这似乎解决了它并且所有导入都很好(据我所知)。

于 2013-04-19T20:45:38.170 回答
0

我上传了两个 cvs 也有类似的情况。PHPMyAdmin 抱怨一个最后有 2 个 NULL 列,另一个有 6 个。我以为我会通过添加额外的假列来“修复”它,但没有。

原来有些数据有双引号,让mysql误以为列数错误。

只需要检查所有数据以确保它是干净的......我知道它更多的是一种解决方法而不是修复。但我能在短时间内做到最好。

于 2012-10-06T22:25:32.603 回答
0

在我的情况下:我将列分隔符从“更改为”在格式特定选项中的 phpMyAdmin 中相同:从“更改为”

于 2020-09-27T00:25:15.407 回答