第1行phpmyadmin上CSV输入中的字段计数无效 [英] Invalid field count in CSV input on line 1 phpmyadmin

查看:3864
本文介绍了第1行phpmyadmin上CSV输入中的字段计数无效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我读了很多线程,但找不到正确的具体答案。当我尝试将其他数据导入现有表时,我收到此错误消息。字段名称都正确对齐,但不是每行都在每个字段中有数据。例如,虽然我有一个名为middle_name的字段,但不是每行都有一个中间名。在导入过程中,此空白字段不会计入字段,从而抛弃字段计数?

I have read many threads but can't find the right specific answer. I get this error message when I try to import additional data into an existing table. The field names are all aligned correctly, but not every row has data in every field. For example, although I have a field named middle_name, not every row has a middle name in it. During the import process, is this blank field not counted as a field and thus throwing off the field count?

我已经设法通过使用导入来获取大部分数据确保我有一个空白列,以允许ID的自动增量,以及留在文件中的标题行,但选择1行跳过导入。

I have managed to get most of the data to import by making sure I had a blank column to allow for the auto-increment of ID, as well as leaving the header row in the file but choosing 1 row to skip on the import.

现在问题是最后一行将不会导入 - 获取错误消息在第19行的CSV输入格式无效。当我将文件复制到文本争议者,最后一行以,,,,,结束。这表示最后5列为空白。

Now the problem is the last row won't import - get error message Invalid format of CSV input on line 19. When I copy the file to Text Wrangler, the last row ends with ,,,,,. This accounts for the last 5 columns which are blank. I need to know what the trick is to get the last row to import.

以下是我一直使用的设置:

Here are the settings I have been using:

推荐答案

在从phpMyAdmin的旧版本升级后,我有类似的问题(带有制表符分隔的文件)。以下几点可能有帮助:

I’ve had similar problems (with a tab-separated file) after upgrading from an ancient version of phpMyAdmin. The following points might be helpful:


  • phpMyAdmin必须正确的列数。在旧版本的phpMyAdmin中,您可以避免为行末尾的列提供空值,但情况并非如此。

  • 如果将Excel文件导出为文本并且行的开始或结束处的列全部为空,则Excel将不会导出这些行的空白。您需要放置某些内容,或留空,然后在文本编辑器中使用正则表达式编辑生成的文件,例如要添加空白的第一行,搜索 ^ ,并替换为(CSV文件)或 \t (制表符文件);在 $ 的结尾处添加两列并替换为 ,, \ t \t 等。

  • 在文件底部添加空行,以避免引用最后一行数据的错误消息。这似乎是在较新版本中修复的错误

  • 在文本编辑器中,还要检查文件编码,因为Excel有时会保存为类似于UTF-16的BOM,phpMyAdmin不喜欢。

  • phpMyAdmin must have he correct number of columns. In older versions of phpMyAdmin you could get away with not supplying empty values for columns at the end of the row, but this is no longer the case.
  • If you export an Excel file to text and columns at the start or end of rows are completely empty, Excel will not export blanks for those rows. You need to put something in, or leave blank then edit the resulting file in a text editor with regular expressions, e.g. to add a blank first row, search for ^ and replace with , (CSV file) or \t (tab file); to add two columns to the end search for $ and replace with ,, or \t\t etc.
  • Add a blank line to the bottom of the file to avoid the error message referring to the last line of data. This seems to be a bug that has been fixed in newer versions.
  • Whilst in the text editor, also check the file encoding as Excel sometimes saves as things like UTF-16 with BOM which phpMyAdmin doesn’t like.

这篇关于第1行phpmyadmin上CSV输入中的字段计数无效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆