本文介绍了如何使用Perl或Python将EOF附加到文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将数据批量插入SQL Server Express数据库中.从Windows XP命令提示符执行bcp时,出现以下错误:

I’m trying to bulk insert data to SQL server express database. When doing bcp from Windows XP command prompt, I get the following error:

C:\temp>bcp  in  -T -f  -S

Starting copy...
SQLState = S1000, NativeError = 0
Error = [Microsoft][SQL Native Client]Unexpected EOF encountered in BCP data-file

0 rows copied.
Network packet size (bytes): 4096
Clock Time (ms.) Total     : 4391

因此,EOF有问题.如何使用Perl或Python将正确的EOF字符附加到此文件?

So, there is a problem with EOF. How to append a correct EOF character to this file using Perl or Python?

推荐答案

EOF是文件末尾.可能发生的情况是文件不完整.该软件需要数据,但是已经没有了.

EOF is End Of File. What probably occurred is that the file is not complete; the software expects data, but there is none to be had anymore.

这些事情发生在以下时间:

These kinds of things happen when:

  • 导出被中断(转储时退出转储软件)
  • 在复制转储文件时中止复制
  • 转储期间磁盘已满

这类事情.

顺便说一句,尽管EOF通常只是文件的结尾,但确实存在一个EOF字符.之所以使用它,是因为终端(命令行)输入实际上并没有像文件那样结束,但是有时需要将EOF传递给这样的实用程序.我不认为它用于实际文件中,至少不表示文件结束.文件系统完全知道文件结束的时间,不需要指示符就可以知道.

By the way, though EOF is usually just an end of file, there does exist an EOF character. This is used because terminal (command line) input doesn't really end like a file does, but it sometimes is necessary to pass an EOF to such a utility. I don't think it's used in real files, at least not to indicate an end of file. The file system knows perfectly well when the file has ended, it doesn't need an indicator to find that out.

编辑 从约翰·马钦(John Machin)提供的评论中毫不含糊地复制

它可以(无意间)在真实文件中发生.它所需要的只是(1)数据输入用户错误地键入Ctrl-Z,在屏幕上看不到任何内容,键入想要的Shift-Z并继续操作;以及(2)验证软件(例如,由公司总裁的侄子编写) ),它很乐意在文本字段中接受Ctrl-anykey,并且您的数据库中有一个炸弹,只是在等待某人对平面文件进行查询.

It can happen (uninentionally) in real files. All it needs is (1) a data-entry user to type Ctrl-Z by mistake, see nothing on the screen, type the intended Shift-Z, and keep going and (2) validation software (written by e.g. the company president's nephew) which happily accepts Ctrl-anykey in text fields and your database has a little bomb in it, just waiting for someone to produce a query to a flat file.

这篇关于如何使用Perl或Python将EOF附加到文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-22 11:51
查看更多