在加载数据时忽略DB2 import命令中的DAT文件中的行尾字符 [英] ignoring end of line character in a DAT file in DB2 import command while loading data

查看:1117
本文介绍了在加载数据时忽略DB2 import命令中的DAT文件中的行尾字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含数据的dat文件。文件中的一行如下:

  HHHH-III | AAAA0000536101 | 2011/11/16 | 0100002MM000 

使用db2 import命令将此数据加载到DB2表中。



问题:
数据中的最后一个字段与数据文件中行末尾的新行字符一起加载,即0100002MM000为最后加载了一些看不见的人物。



相同的字段正在从其他文件加载到其他表中。但在其他的dat文件中,它位于中间的一行,如下所示:

  2011/11/16 | 0100002MM000 | HHHH-III | AAAA | BBBBB | KDKDKDKDDKD管理| C 

所以稍后比较0100002MM000从第一个表与0100002MM000在第二个表中失败。



如何解决这个问题?



所以在这种情况下,

解决方案

该文件是否有Windows\r\\\
(CRLF)行终止符,导入期待Unix\\\
终结符所以最后导入\?如果是这样,修复程序只是将文件转换为Unix格式 - 有很多工具可以做到这一点,或者你可以通过编程方式轻松实现。



通过在二进制文件编辑器中打开文件并查看行终止符来检查是否是这种情况 - 如果使用0x0D 0x0A(或UTF-16等效),那么这是Windows行终止符。即使它不是,那么查看二进制文件编辑器会显示最后一行是什么 - 也许有一个空字符(0x00)不知何故如果是这种情况,那么应该很容易剥离,但是您应该首先看看是否可以通过修复生成文件的代码来避免这个问题。 (这个可能不在你的控制之下,但可能不是。)


I have a dat file containing data. A line from the file is as below:

HHHH-III|AAAA0000536101|2011/11/16|0100002MM000

This data is being loaded in a DB2 table using db2 import command.

Issue: The last field in the data gets loaded along with the "new line" character at the end of the line in the dat file i.e. 0100002MM000 is getting loaded with some invisible character at the end.

Same field is being loaded in other table from other file. But in the other dat file it is at the centre somewhere in the line as below:

2011/11/16|0100002MM000|HHHH-III|AAAA|BBBBB|KDKDKDKDDKD MANAGED|C

So later on comparing 0100002MM000 from first table with 0100002MM000 in second table is failing.

How to resolve this issue?

So in this case,

解决方案

Is it possible that the file has Windows "\r\n" (CRLF) line terminators, and the import is expecting Unix "\n" terminators, so it's importing the "\r" at the end? If so, the fix is just to convert the file to the Unix format - there are lots of tools around to do that, or you can do so programmatically easily enough.

Check whether this is the case by opening up the file in binary file editor and looking at the line terminator - if it's using 0x0D 0x0A (or a UTF-16 equivalent) then that's the Windows line terminator. Even if it's not that, looking in a binary file editor will show you what is at the end of the line - maybe there's a null character (0x00) which has got in there somehow. If that's the case, again it should be easy to strip but you should see whether you can avoid the problem in the first place by fixing the code which generates the file to start with. (This may be out of your control, but it may not be.)

这篇关于在加载数据时忽略DB2 import命令中的DAT文件中的行尾字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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