我的客户端需要将文本文件导入系统,但其文本文件是管道分隔的“|”。他们还需要导出一些数据到相同的格式(管道分隔)。我被要求使用Powerbuilder 12.是否可以直接使用PipeDelimited文本文件导入文件?我想跳过“FOR LOOP MID GET”方法,直接进入importfile然后update()。 dw.saveas()也一样。Powerbuilder ImportFile/SaveAs
0
A
回答
0
,据我所知,我们是不是幸运的进口,因为我们无法定义的分隔符,但这里是一个小的解决方法:
- 文件读入到一个字符串变量
- 更换管道|以逗号,
- 导入字符串作为CSV到DW
我做了一个小测试程序对你和它的工作。我的文本文件是这样的:
Col1中| col2的| COL3
AAA | BBB | CCC
这里是导入代码:
string ls_import, ls_export
long ll_filehandle, ll_readbytes
// IMPORT
ll_filehandle = FileOpen("d:\Work\StackExchange\pipes.txt", TextMode!)
ll_readbytes = FileReadEx(ll_filehandle, ls_import)
if ll_filehandle = -1 or IsNull(ll_filehandle) then
else
ls_import = f_glo_replace_all(ls_import, "|", ",")
dw_1.ImportString(CSV!, ls_import)
end if
随着我们有更多的运气出口。有在其中您可以自定义分隔的出口数据窗口方法:
所以进口是这样的:
dw_1.SaveAsFormattedText(“d:\工作\ StackExchange \ export_pipes .TXT”,EncodingANSI!‘|’)
当然,你将需要全局替换函数的代码:
这里是源:
global type f_glo_replace_all from function_object
end type
forward prototypes
global function string f_glo_replace_all (string source, string look_for, string replace_with)
end prototypes
global function string f_glo_replace_all (string source, string look_for, string replace_with);/*A String Occurrence Search and Replace RoutineThe following code demonstrates a string occurrence search and replaceroutine.This routine works generically for any string. For example,if old_str = "red" and new_str ="green", all occurrences of "red" inside of mystring will be replaced with "green".
Parameters
Name = source Type = String
Name = look_for Type = String
Name = replace_with Type = String
*/
int start_pos=1,len_look_for
len_look_for = len(lower(look_for))
//find the first occurrence of look_for ...
start_pos = Pos(lower(source),lower(look_for), start_pos)
//only enter the loop if you find whats in look_for
DO WHILE start_pos > 0
//replace look_for with replace_with ...
source = Replace(source,start_pos,Len_look_for,replace_with)
//find the next occurrence of
start_pos = Pos(lower(source), lower(look_for), start_pos+Len(replace_with))
LOOP
return source
end function
我希望这有助于!
Br。 Gábor
0
不,你想要的方式是不可能的。您需要编写自己的ImportFile版本,抱歉,这不是您想要的答案。
相关问题
- 1. Powerbuilder WebCam
- 2. PowerBuilder Tabpage
- 3. PowerBuilder v8与PowerBuilder v12之间的区别
- 4. 我想在PowerBuilder
- 5. NxTera with PowerBuilder
- 6. Powerbuilder Dynamic Array Manipulation
- 7. PowerBuilder的运行
- 8. 阵列在PowerBuilder
- 9. PowerBuilder到ASP.NET
- 10. PowerBuilder 12.5教程
- 11. Powerbuilder资源
- 12. 在PowerBuilder应用
- 13. PowerBuilder web部署
- 14. PowerBuilder DSN创建
- 15. Sonarqube 5.0 with powerbuilder
- 16. PowerBuilder的OrcaScript:
- 17. 分组treeview powerbuilder
- 18. 图像powerbuilder
- 19. Powerbuilder日期数学
- 20. PowerBuilder - SCAUTIL.DLL函数ENC()
- 21. PowerBuilder数据窗口
- 22. Powerbuilder创建文件
- 23. Powerbuilder修改行列
- 24. PowerBuilder窗口大小
- 25. PowerBuilder的12.5迁移
- 26. 写入和用PowerBuilder
- 27. PowerBuilder 11.5 .NET DLL pbl
- 28. PowerBuilder catch检索ORA
- 29. 无法在PowerBuilder 9.0
- 30. AcceptText()不工作PowerBuilder
我认为这与“FOR LOOP MID GET”是一样的,因为它需要一行一行地读取,对于小于10的细节项目,这将是实际的,但是我面对每个文件每天约1000行。可悲的是我觉得我没有任何选择。 – Sid 2013-03-14 07:40:03
对于导入yes是这样的,除了一次读取文件,只更改管道类似于“每行读取”方法,但对于导出有一个很好的解决方案! – DARKinVADER 2013-03-14 09:08:59