Formatting 为什么在导出到正在进行4GL的文本文件时,带空格的字段值包含新行?
我能够将数据导出到文本文件,但文本文件中的格式不好。例如,当一个字段值中有空格时,它在文件中包含一个新行 样本数据: 846438828 | 10121803 |海因|凯蒂| 270 |卵石Formatting 为什么在导出到正在进行4GL的文本文件时,带空格的字段值包含新行?,formatting,progress-4gl,openedge,Formatting,Progress 4gl,Openedge,我能够将数据导出到文本文件,但文本文件中的格式不好。例如,当一个字段值中有空格时,它在文件中包含一个新行 样本数据: 846438828 | 10121803 |海因|凯蒂| 270 |卵石 CREEK | DR | | | | | usa | GA | 30605 | | | 7天| 1 | 2| 84248660 | 1012 |冈特|勒威尔| 230 |麦克杜菲|博士|雅典| GA | 30605 | 7065430640 |周五-周日| 1 | 2| 889388948 | 101205
CREEK | DR | | | | | usa | GA | 30605 | | | 7天| 1 | 2| 84248660 | 1012 |冈特|勒威尔| 230 |麦克杜菲|博士|雅典| GA | 30605 | 7065430640 |周五-周日| 1 | 2| 889388948 | 101205 |周| J D | 183 | MELL | ST | | GA | 30605 | 7065481437 | Sunnonly | 1 | 2| streetname“PEBBLE”CREEK字段的值,但在报告中类似于: 卵石 小溪 为什么会发生这种情况
def var v-copies as inte no-undo.
def var v-phone as char format "x(16)" no-undo.
def var v-loc as char no-undo.
def var v-file as char format "x(30)" no-undo.
def var v-demoid as char format "x(20)" no-undo.
def var v-email as char format "x(30)" no-undo.
def var v-hostname as char format "x(20)" no-undo.
def var v-RouteIDs as char no-undo.
def var v-Product as char no-undo.
def var v-ExDir as char format "x(80)" no-undo.
def var v-LookBack as int no-undo init 90.
{tools/altpubs/audit/var.i}
{tools/altpubs/audit/procedures.i}
def stream sout.
def temp-table tt-demo
field entityid as int format ">>>>>>>>>9"
field answer like DemographicAnswer.Answer.
v-ConfigFile = search(v-ConfigFile).
if v-ConfigFile = ? then do:
message "config file config.csv was not found" view-as alert-box.
RETURN "ERROR".
end.
input from value(v-ConfigFile).
run ReadConfig.
input close.
for each tt-Config where tt-Config.Section = 'local' and
tt-Config.SectionValue <> ?:
v-loc = tt-Config.SectionValue.
case tt-Config.SettingName:
when 'ExchDir' then v-ExDir = tt-Config.SettingValue.
when 'Product' then v-Product = tt-Config.SettingValue.
when 'Routes' then v-RouteIDs = tt-Config.SettingValue.
when 'LookBack' then
do:
v-LookBack = integer(tt-Config.SettingValue) no-error.
if error-status:error then v-LookBack = 90.
end.
end.
end.
v-ExDir = v-Exdir + lc(v-loc) + "/".
file-info:file-name = v-ExDir.
if not( file-info:file-type begins "D") or file-info:file-type = ? then
do:
unix silent makedir value(v-ExDir) && chmod 777 value(v-ExDir).
file-info:file-name = v-ExDir.
end.
assign
v-File = v-ExDir + lc(v-Product) + "Audit" +
string(month(today),"99") + "-" +
string(day(today),"99") + "-" +
substring(string(year(today),"9999"),3) + ".txt".
for each DemographicAnswer where DemographicAnswer.DemographicId = v-RouteIDs
no-lock:
create tt-demo.
assign tt-demo.entityid = int(DemographicAnswer.EntityId)
tt-demo.answer = DemographicAnswer.Answer.
end.
output stream sout to value(v-file).
put stream sout unformatted
"HEADER B2 " string(today) skip.
for each tt-demo,
each Subscription no-lock
where Product = v-product
and SubscriptionID = tt-demo.entityid
and Subscriber = yes
and Getspaper = yes:
find last RouteSubscription of Subscription no-lock no-error.
if available routeSubscription then do:
for each Occupant of Subscription no-lock,
each Address of Subscription no-lock:
find OccupantPhone of Occupant no-lock no-error.
if available OccupantPhone then
v-phone = OccupantPhone.AreaCode + OccupantPhone.Phone.
else
v-phone = "".
find last OccupantEmail of Occupant no-lock no-error.
if available OccupantEmail then
v-email = OccupantEmail.EmailAddress.
else
v-email = "".
case DeliveryScheduleId:
when "MON-FRI" then v-copies = RouteSubscription.Copies[2].
when "FRI-SUN" then v-copies = RouteSubscription.Copies[1].
when "SUNONLY" then v-copies = RouteSubscription.Copies[1].
when "7DAY" then v-copies = RouteSubscription.Copies[1].
when "MON-SAT" then v-copies = RouteSubscription.Copies[2].
when "THUONLY" then v-copies = RouteSubscription.Copies[5].
when "WEDONLY" then v-copies = RouteSubscription.Copies[4].
when "SATSUN" then v-copies = RouteSubscription.Copies[1].
end case.
put stream sout unformatted
tt-demo.Answer "|"
Subscription.SubscriptionId "|"
Subscription.Product "|"
Occupant.LastName "|"
Occupant.FirstName "|"
trim( Address.HouseNumber) "|"
trim(Address.Postdirectional) "|"
trim(Address.StreetName) "|"
trim(Address.StreetSuffixId) "|"
trim(Address.postdirectional) "|"
trim(Address.UnitDesignatorID + trim(Address.UnitNumber)) "|"
Address.CityId "|"
Address.StateId "|"
Address.ZipCode "|"
v-phone "|"
Subscription.DeliveryScheduleId "|"
v-copies "|"
"2" "|"
v-email skip.
end.
end.
end.
put stream sout unformatted
"TRAILER ".
output stream sout close.
def var v复制为inte no undo。
def var v-phone为字符格式“x(16)”无撤销。
def var v-loc作为字符,不可撤消。
def var v-file为字符格式“x(30)”无撤消。
def var v-demoid为字符格式“x(20)”无撤消。
def var v-email为字符格式“x(30)”无撤销。
def var v-hostname为字符格式“x(20)”不撤消。
def var v-RouteIDs为char no undo。
def var v-Product作为字符,不可撤消。
def var v-ExDir为字符格式“x(80)”无撤消。
def var v-LookBack为int no undo init 90。
{tools/altpubs/audit/var.i}
{tools/altpubs/audit/procedures.i}
def流sout。
def温度表tt演示
字段entityid为int格式“>>>>>>>>9”
字段答案与人口统计答案类似。答案。
v-ConfigFile=搜索(v-ConfigFile)。
如果v-ConfigFile=?然后做:
消息“未找到配置文件config.csv”作为警报框查看。
返回“错误”。
结束。
从值(v-ConfigFile)输入。
运行ReadConfig。
输入关闭。
对于每个tt配置,其中tt-Config.Section='local'和
tt-Config.SectionValue?:
v-loc=tt-Config.SectionValue。
案例tt-Config.SettingName:
当“ExchDir”时,则v-ExDir=tt-Config.SettingValue。
当“Product”时,则v-Product=tt-Config.SettingValue。
当“路由”时,则v-RouteIDs=tt-Config.SettingValue。
什么时候“回头看”呢
做:
v-LookBack=integer(tt Config.SettingValue)无错误。
如果错误状态:error,则v-LookBack=90。
结束。
结束。
结束。
v-ExDir=v-ExDir+lc(v-loc)+“/”。
文件信息:文件名=v-ExDir。
如果不是(文件信息:文件类型以“D”开头)或文件信息:文件类型=?然后
做:
unix静默makedir值(v-ExDir)和&chmod 777值(v-ExDir)。
文件信息:文件名=v-ExDir。
结束。
分配
v-File=v-ExDir+lc(v-Product)+“审计”+
字符串(月份(今天),“99”)+“-”+
字符串(日(今天),“99”)+“-”+
子字符串(字符串(年份(今天),“9999”),3)+“.txt”。
对于每个DemographicAnswer,其中DemographicAnswer.DemographicId=v-RouteIDs
无锁:
创建tt演示。
分配tt-demo.entityid=int(DemographicAnswer.entityid)
tt-demo.answer=人口统计学答案。
结束。
输出流输出到值(v文件)。
将流放在未格式化的位置
“标题B2”字符串(今天)跳过。
对于每个tt演示,
每个订阅都没有锁
其中Product=v-Product
和SubscriptionID=tt-demo.entityid
和订户=是
和Getspaper=yes:
查找订阅的最后路由订阅无锁定无错误。
如果有routeSubscription,请执行以下操作:
对于每个无锁的乘客,
订阅的每个地址都没有锁:
查找占用者的占用电话无锁无错误。
如果有,请拨打电话
v-phone=职业电话.AreaCode+职业电话.phone。
其他的
v-phone=”“。
查找最后一封占用者邮件无锁无错误。
如果有的话,那就发邮件吧
v-email=Occupentemail.EmailAddress。
其他的
v-email=”“。
案例交付时间表ID:
当“周一至周五”时,则v-copies=RouteSubscription.copies[2]。
当“FRI-SUN”时,则v-copies=RouteSubscription.copies[1]。
当“SUNONLY”时,则v-copies=RouteSubscription.copies[1]。
当“7天”时,v-copies=RouteSubscription.copies[1]。
当“MON-SAT”时,则v-copies=RouteSubscription.copies[2]。
当“THUONLY”时,则v-copies=RouteSubscription.copies[5]。
当“WEDONLY”时,则v-copies=RouteSubscription.copies[4]。
当“SATSUN”时,则v-copies=RouteSubscription.copies[1]。
结案。
将流放在未格式化的位置
tt-demo.Answer“|”
Subscription.SubscriptionId“|”
订阅。产品“|”
Occompant.LastName“|”
Occompant.FirstName“|”
修剪(地址、门牌号)“|”
修剪(地址:后定向)“|”
trim(地址:StreetName)“|”
trim(地址:StreetSuffixId)“|”
修剪(地址:后定向)“|”
修剪(Address.UnitDesignatorID+修剪(Address.UnitNumber))“|”
Address.CityId“|”
Address.StateId“|”
Address.ZipCode“|”
v-phone“|”
Subscription.DeliveryScheduleId“|”
v-副本“|”
"2" "|"
v-email跳过。
结束。
结束。
结束。
将流放在未格式化的位置
“拖车”。
输出流关闭。
这实际上可能只取决于几件事,但如果没有看到您的代码,很难回答
1) 那里真的没有新的生产线。只有当你打开文件时,你的文本编辑器会断线,所以看起来才像这样。如果是这种情况,最大化/更改编辑器的窗口大小将更改新行的显示位置
2) 这个领域真的有一条新的生产线。这将被出口。如果使用“导出”导出值,则可以尝试执行以下操作以替换新行字符:
EXPORT REPLACE(streetname, "~n","").
如果这起作用,则数据库中有新行
3) 导出数据的方式有问题。由于您没有发布示例代码(这样做总是一个好主意),我们无法了解这一点
我赌1号或2号。如果您使用像EXPORT这样简单的导出方法,您真的不应该遇到麻烦…与Jens所说的差不多(我会将此作为注释,但堆栈溢出不允许我…) 尝试在记事本++中打开文件并禁用Vie
FUNCTION stringExport RETURNS CHAR
( INPUT p-input AS CHAR ):
RETURN TRIM(REPLACE(REPLACE(p-input,CHR(13),''),CHR(10),'')).
END FUNCTION. /* stringExport */
PUT STREAM sout UNFORMATTED
stringExport(Occupant.FirstName) "|"
stringExport(Address.HouseNumber) "|" SKIP.
for each address no-lock:
display procedure.postdirectional.
end.