中国DOS联盟论坛

中国DOS联盟

-- 联合DOS 推动DOS 发展DOS --

联盟域名:www.cn-dos.net  论坛域名:www.cn-dos.net/forum
DOS,代表着自由开放与发展,我们努力起来,学习FreeDOS和Linux的自由开放与GNU精神,共同创造和发展美好的自由与GNU GPL世界吧!

游客:  注册 | 登录 | 命令行 | 会员 | 搜索 | 上传 | 帮助 »
« [1] [2] »
作者:
标题: 求助,数据结构的转换问题 上一主题 | 下一主题
beyond125
初级用户





积分 92
发帖 35
注册 2008-3-25
状态 离线
『楼 主』:  求助,数据结构的转换问题

各位大虾你好,我有个数据结构转换的问题,请各位帮忙,这里先谢谢了
我现在有一个上传的文本文件,文件名为1.loc 现取部分数据,格式如下:
LocateMode,FileIndex,Depth,LocateCurrent,PcmCurrent,PcmPhase,Signal,UTC,LatitudeAngle,LatitudeDirection,LongitudeAngle,LongitudeDirection,GpsFix,NumberSatellites,HorizontalDilution,AltitudeValue,AltitudeUnits,GeoidHeightValue,GeoidHeightUnits,DgpsTime,DgpsStationId,TimeIndicator
ELCD,1,1.37,0.69,0.08,150.01,0.00,141630.00,0.00,0,0.00,0,0,0,0.00,0.00,0,0.00,0,0,0,0
ELCD,2,1.39,0.50,0.04,158.08,0.00,141633.00,0.00,0,0.00,0,0,0,0.00,0.00,0,0.00,0,0,0,0
ELCD,3,2.19,0.38,0.04,15.94,0.00,141635.00,0.00,0,0.00,0,0,0,0.00,0.00,0,0.00,0,0,0,0
ELF,14,0.81,53.23,1.41,0.00,0.00,150520.00,0.00,0,0.00,0,0,0,0.00,0.00,0,0.00,0,0,0,0
ELF,15,0.71,47.25,1.37,0.00,0.00,150522.00,0.00,0,0.00,0,0,0,0.00,0.00,0,0.00,0,0,0,0

现在我想将其中的LocateMode字段下的所有ELCD模式里的FileIndex字段,Depth字段,PcmCurrnt字段下的数据提出来,变为如下结构,并输出成1.csv文本文件
1.csv文本文件格式如下
Log        Distance        4Hz        4Hz                      Depth
#        (m)                (mA)        (dBmA)                      (cm)
1,                ,        80,        38.06179974,                137,
2,                ,        40,        32.04119983,                139,
3,                ,        40,        32.04119983,                219,

注:上面的1.csv文件是以逗号做为分隔符,在这个文件里的log字段就是1.loc文件里的FileIndex字段,Distance字段是空出的字段名,4Hz(mA)字段就是1.loc文件里的PcmCurrent字段乘以1000得到的,4Hz(dBmA)字段是前面4Hz(mA)这个字段的数据取对数,再乘以20得到的。(即20*lg(前一列的数据)),Depth(cm)字段就是1.loc文件中的Depth字段的数据乘以100

我想问用批处理或者vbs如何实现这种转换。我在这里再次先谢谢各位网友大虾们。

[ Last edited by beyond125 on 2008-4-7 at 04:31 PM ]

2008-4-7 14:10
查看资料  发送邮件  发短消息 网志   编辑帖子  回复  引用回复
beyond125
初级用户





积分 92
发帖 35
注册 2008-3-25
状态 离线
『第 2 楼』:  求助,数据结构的转换问题

各位大虾你好,我有个数据结构转换的问题,请各位帮忙,这里先谢谢了
我现在有一个文本文件,文件名为1.loc 现取部分数据,格式如下:
LocateMode,FileIndex,Depth,LocateCurrent,PcmCurrent,PcmPhase,Signal,UTC,LatitudeAngle,LatitudeDirection,LongitudeAngle,LongitudeDirection,GpsFix,NumberSatellites,HorizontalDilution,AltitudeValue,AltitudeUnits,GeoidHeightValue,GeoidHeightUnits,DgpsTime,DgpsStationId,TimeIndicator
ELCD,1,1.37,0.69,0.08,150.01,0.00,141630.00,0.00,0,0.00,0,0,0,0.00,0.00,0,0.00,0,0,0,0
ELCD,2,1.39,0.50,0.04,158.08,0.00,141633.00,0.00,0,0.00,0,0,0,0.00,0.00,0,0.00,0,0,0,0
ELCD,3,2.19,0.38,0.04,15.94,0.00,141635.00,0.00,0,0.00,0,0,0,0.00,0.00,0,0.00,0,0,0,0
ELF,14,0.81,53.23,1.41,0.00,0.00,150520.00,0.00,0,0.00,0,0,0,0.00,0.00,0,0.00,0,0,0,0
ELF,15,0.71,47.25,1.37,0.00,0.00,150522.00,0.00,0,0.00,0,0,0,0.00,0.00,0,0.00,0,0,0,0

现在我想将其中的LocateMode字段下的所有ELCD模式里的FileIndex字段,Depth字段,PcmCurrnt字段下的数据提出来,变为如下结构,并输出成1.csv文本文件
1.csv文本文件格式如下
Log        Distance        4Hz        4Hz                      Depth
#        (m)                (mA)        (dBmA)                      (cm)
1,                ,        80,        38.06179974,                137,
2,                ,        40,        32.04119983,                139,
3,                ,        40,        32.04119983,                219,

注:下面的1.csv文件是以逗号为分隔符,在这个文件里的log字段就是1.loc文件里的FileIndex字段,Distance字段是空出的字段名,4Hz(mA)字段就是1.loc文件里的PcmCurrent字段乘以1000得到的,4Hz(dBmA)字段是前面4Hz(mA)这个字段的数据取对数,再乘以20得到的。(即20*log(前一列的数据)),Depth(cm)字段就是1.loc文件中的Depth字段的数据乘以100

这里想说,用批处理或者vbs如何实现这种转换。我先谢谢各位网友大虾们。

2008-4-7 14:26
查看资料  发送邮件  发短消息 网志   编辑帖子  回复  引用回复
abcd
银牌会员





积分 1436
发帖 739
注册 2007-10-11
状态 离线
『第 3 楼』:  

log是自然对数,还是??

2008-4-7 14:31
查看资料  发短消息 网志  OICQ (470237592)  编辑帖子  回复  引用回复
abcd
银牌会员





积分 1436
发帖 739
注册 2007-10-11
状态 离线
『第 4 楼』:  

一帖多发,扣分。

2008-4-7 15:07
查看资料  发短消息 网志  OICQ (470237592)  编辑帖子  回复  引用回复
beyond125
初级用户





积分 92
发帖 35
注册 2008-3-25
状态 离线
『第 5 楼』:  

log是以10为底的常用对数!!!

2008-4-7 16:30
查看资料  发送邮件  发短消息 网志   编辑帖子  回复  引用回复
abcd
银牌会员





积分 1436
发帖 739
注册 2007-10-11
状态 离线
『第 6 楼』:  


dim fso, f1, f2, regex, arr
dim str, num1, num2, num3, fn1, fn2
fn1="1.loc"
fn2="1.csv"
set regex=new regexp
regex.pattern="^ELCD"
regex.ignorecase=true

set fso=createobject("scripting.filesystemobject")
set f2=fso.createtextfile(fn2,true)
f2.writeline "Log        Distance        4Hz        4Hz                      Depth"
f2.writeline "#         (m)              (mA)       (dBmA)                   (cm)"
set f1=fso.opentextfile(fn1,1)
do while f1.atendofstream<>true
  str=f1.readline
  if regex.test(str) then
     arr=split(str,",")
     num1=arr(4)*1000
     num2=log(num1)/log(10)*20
     num3=arr(2)*100
f2.writeline arr(1)&","&"         ,               "&num1&",        "&num2&",         "&num3&","
  end if
loop
f2.close
f1.close
msgbox "OK"
set f1=nothing
set f2=nothing
set regex=nothing
set fso=nothing
自己修改该测试一下吧

2008-4-7 16:31
查看资料  发短消息 网志  OICQ (470237592)  编辑帖子  回复  引用回复
beyond125
初级用户





积分 92
发帖 35
注册 2008-3-25
状态 离线
『第 7 楼』:  

谢谢,我试试

2008-4-7 16:32
查看资料  发送邮件  发短消息 网志   编辑帖子  回复  引用回复
beyond125
初级用户





积分 92
发帖 35
注册 2008-3-25
状态 离线
『第 8 楼』:  

你好,为什么,在log调用上出现了错误, 显示的是无效的过程和参数:"log",显示代码是:800A0005

2008-4-7 16:50
查看资料  发送邮件  发短消息 网志   编辑帖子  回复  引用回复
beyond125
初级用户





积分 92
发帖 35
注册 2008-3-25
状态 离线
『第 9 楼』:  

还有,如果用批处理如何的实现!!

2008-4-7 16:51
查看资料  发送邮件  发短消息 网志   编辑帖子  回复  引用回复
abcd
银牌会员





积分 1436
发帖 739
注册 2007-10-11
状态 离线
『第 10 楼』:  

只测试了

  Quote:
LocateMode,FileIndex,Depth,LocateCurrent,PcmCurrent,PcmPhase,Signal,UTC,LatitudeAngle,LatitudeDirection,LongitudeAngle,LongitudeDirection,GpsFix,NumberSatellites,HorizontalDilution,AltitudeValue,AltitudeUnits,GeoidHeightValue,GeoidHeightUnits,DgpsTime,DgpsStationId,TimeIndicator
ELCD,1,1.37,0.69,0.08,150.01,0.00,141630.00,0.00,0,0.00,0,0,0,0.00,0.00,0,0.00,0,0,0,0
ELCD,2,1.39,0.50,0.04,158.08,0.00,141633.00,0.00,0,0.00,0,0,0,0.00,0.00,0,0.00,0,0,0,0
ELCD,3,2.19,0.38,0.04,15.94,0.00,141635.00,0.00,0,0.00,0,0,0,0.00,0.00,0,0.00,0,0,0,0
ELF,14,0.81,53.23,1.41,0.00,0.00,150520.00,0.00,0,0.00,0,0,0,0.00,0.00,0,0.00,0,0,0,0
ELF,15,0.71,47.25,1.37,0.00,0.00,150522.00,0.00,0,0.00,0,0,0,0.00,0.00,0,0.00,0,0,0,0

,似乎没问题。

用批处理的话,能解决log算法,就简单了。

2008-4-7 16:55
查看资料  发短消息 网志  OICQ (470237592)  编辑帖子  回复  引用回复
beyond125
初级用户





积分 92
发帖 35
注册 2008-3-25
状态 离线
『第 11 楼』:  

输出文档只显示循环了十次,能不能自动搜索文件的行数,然后定位输出!!

我的原始部分文件也就是1.loc文件,数据如下,用你的程序运行后就出错了.LocateMode,FileIndex,Depth,LocateCurrent,PcmCurrent,PcmPhase,Signal,UTC,LatitudeAngle,LatitudeDirection,LongitudeAngle,LongitudeDirection,GpsFix,NumberSatellites,HorizontalDilution,AltitudeValue,AltitudeUnits,GeoidHeightValue,GeoidHeightUnits,DgpsTime,DgpsStationId,TimeIndicator
ELCD,33,0.49,0.39,0.03,43.52,0.00,150603.00,0.00,0,0.00,0,0,0,0.00,0.00,0,0.00,0,0,0,0
ELCD,34,0.49,0.43,0.03,45.62,0.00,150605.00,0.00,0,0.00,0,0,0,0.00,0.00,0,0.00,0,0,0,0
LFCD,35,13.77,0.01,0.02,59.29,0.00,150608.00,0.00,0,0.00,0,0,0,0.00,0.00,0,0.00,0,0,0,0
ELCD,36,0.91,1.72,0.08,70.81,0.00,150610.00,0.00,0,0.00,0,0,0,0.00,0.00,0,0.00,0,0,0,0
ELCD,37,0.85,1.90,0.19,358.32,0.00,150612.00,0.00,0,0.00,0,0,0,0.00,0.00,0,0.00,0,0,0,0
ELCD,38,1.09,2.04,0.20,355.08,0.00,150615.00,0.00,0,0.00,0,0,0,0.00,0.00,0,0.00,0,0,0,0
LFCD,39,12.81,0.02,0.07,163.66,0.00,150617.00,0.00,0,0.00,0,0,0,0.00,0.00,0,0.00,0,0,0,0
ELCD,40,14.98,0.03,0.03,109.56,0.00,150619.00,0.00,0,0.00,0,0,0,0.00,0.00,0,0.00,0,0,0,0
ELCD,41,2.36,1.41,0.39,352.90,0.00,150621.00,0.00,0,0.00,0,0,0,0.00,0.00,0,0.00,0,0,0,0
ELCD,42,1.56,0.57,0.12,258.26,0.00,150624.00,0.00,0,0.00,0,0,0,0.00,0.00,0,0.00,0,0,0,0
ELCD,43,1.07,0.77,0.04,273.01,0.00,150626.00,0.00,0,0.00,0,0,0,0.00,0.00,0,0.00,0,0,0,0
ELCD,44,14.98,1.98,0.12,178.76,0.00,150628.00,0.00,0,0.00,0,0,0,0.00,0.00,0,0.00,0,0,0,0
ELCD,45,0.29,0.05,0.00,184.40,0.00,150631.00,0.00,0,0.00,0,0,0,0.00,0.00,0,0.00,0,0,0,0
ELCD,46,1.08,5.93,0.09,4.63,0.00,150633.00,0.00,0,0.00,0,0,0,0.00,0.00,0,0.00,0,0,0,0
ELCD,47,2.12,6.04,0.25,182.56,0.00,150635.00,0.00,0,0.00,0,0,0,0.00,0.00,0,0.00,0,0,0,0
ELCD,48,2.11,9.19,0.14,4.38,0.00,150637.00,0.00,0,0.00,0,0,0,0.00,0.00,0,0.00,0,0,0,0
ELCD,49,0.82,3.03,0.05,5.67,0.00,150640.00,0.00,0,0.00,0,0,0,0.00,0.00,0,0.00,0,0,0,0
ELCD,50,0.70,0.07,0.00,166.25,0.00,150642.00,0.00,0,0.00,0,0,0,0.00,0.00,0,0.00,0,0,0,0
CPS,13,11.38,0.01,0.00,0.00,0.00,150517.00,0.00,0,0.00,0,0,0,0.00,0.00,0,0.00,0,0,0,0
ELF,14,0.81,53.23,1.41,0.00,0.00,150520.00,0.00,0,0.00,0,0,0,0.00,0.00,0,0.00,0,0,0,0
ELF,15,0.71,47.25,1.37,0.00,0.00,150522.00,0.00,0,0.00,0,0,0,0.00,0.00,0,0.00,0,0,0,0
ELF,16,0.74,41.34,1.50,0.00,0.00,150524.00,0.00,0,0.00,0,0,0,0.00,0.00,0,0.00,0,0,0,0
ELF,17,14.14,0.33,0.15,0.00,0.00,150526.00,0.00,0,0.00,0,0,0,0.00,0.00,0,0.00,0,0,0,0
ELCD,34,0.49,0.43,0.03,45.62,0.00,150605.00,0.00,0,0.00,0,0,0,0.00,0.00,0,0.00,0,0,0,0
LFCD,35,13.77,0.01,0.02,59.29,0.00,150608.00,0.00,0,0.00,0,0,0,0.00,0.00,0,0.00,0,0,0,0
ELCD,36,0.91,1.72,0.08,70.81,0.00,150610.00,0.00,0,0.00,0,0,0,0.00,0.00,0,0.00,0,0,0,0
ELCD,37,0.85,1.90,0.19,358.32,0.00,150612.00,0.00,0,0.00,0,0,0,0.00,0.00,0,0.00,0,0,0,0
ELCD,38,1.09,2.04,0.20,355.08,0.00,150615.00,0.00,0,0.00,0,0,0,0.00,0.00,0,0.00,0,0,0,0
LFCD,39,12.81,0.02,0.07,163.66,0.00,150617.00,0.00,0,0.00,0,0,0,0.00,0.00,0,0.00,0,0,0,0
ELCD,40,14.98,0.03,0.03,109.56,0.00,150619.00,0.00,0,0.00,0,0,0,0.00,0.00,0,0.00,0,0,0,0

2008-4-7 17:03
查看资料  发送邮件  发短消息 网志   编辑帖子  回复  引用回复
abcd
银牌会员





积分 1436
发帖 739
注册 2007-10-11
状态 离线
『第 12 楼』:  

问题在ELCD,45,0.29,0.05,0.00,184.40,0.00,150631.00,0.00,0,0.00,0,0,0,0.00,0.00,0,0.00,0,0,0,0
这些行。对数的真数是不能为0的。

自己的数据问题

[ Last edited by abcd on 2008-4-7 at 05:11 PM ]

2008-4-7 17:08
查看资料  发短消息 网志  OICQ (470237592)  编辑帖子  回复  引用回复
beyond125
初级用户





积分 92
发帖 35
注册 2008-3-25
状态 离线
『第 13 楼』:  

对,我现在在找,谢谢你,我再试试!!!

2008-4-7 17:14
查看资料  发送邮件  发短消息 网志   编辑帖子  回复  引用回复
beyond125
初级用户





积分 92
发帖 35
注册 2008-3-25
状态 离线
『第 14 楼』:  

你好,能否将"ELCD"这几个字符,输出,输入文件名用对话框的形式表现出来,就不用用固定的文件名了.这样用vbs如何实现.

2008-4-7 17:22
查看资料  发送邮件  发短消息 网志   编辑帖子  回复  引用回复
knoppix7
银牌会员





积分 1287
发帖 634
注册 2007-5-2
来自 cmd.exe
状态 离线
『第 15 楼』:  

参见 for /f帮助

2008-4-7 19:11
查看资料  发短消息 网志   编辑帖子  回复  引用回复
« [1] [2] »
请注意:您目前尚未注册或登录,请您注册登录以使用论坛的各项功能,例如发表和回复帖子等。


可打印版本 | 推荐给朋友 | 订阅主题 | 收藏主题



论坛跳转: