| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1082 人关注过本帖
标题:文本格式中数据转换问题
取消只看楼主 加入收藏
puchengguo
Rank: 1
等 级:新手上路
帖 子:14
专家分:0
注 册:2008-9-18
收藏
 问题点数:0 回复次数:2 
文本格式中数据转换问题
先给文本文件起个名叫 111 ,谁能把第3列中相同的数字换成1 2 2 …… 3的形式,简单说转换后第3列的结果像是这样

1     1
1     2
1     2
1     2
1     2
1     3
2     1
2     2
2     2
2     3



内容如下:
  3.71273374E+05  2.73530001E+05    1                              
  3.71210906E+05  2.73597001E+05    1                           
  3.71063093E+05  2.73755500E+05    1   
  3.70972156E+05  2.73853001E+05    1                           
  3.70846875E+05  2.73987500E+05    1                              
  3.70665125E+05  2.74182499E+05    1                              
  3.70781905E+05  2.73470500E+05    2                              
  3.70483499E+05  2.73790500E+05    2                              
  3.70244719E+05  2.74046499E+05    2                              
  3.69827001E+05  2.74494501E+05    2                              
  3.70834406E+05  2.73707501E+05    3                              
  3.70615280E+05  2.73942501E+05    3                              
  3.70513156E+05  2.74052001E+05    3                              
  3.70399500E+05  2.74174000E+05    3                              
  3.71581376E+05  2.74079501E+05    4                           
  3.71496062E+05  2.74171000E+05    4                             
  3.71376687E+05  2.74299000E+05    4                              
  3.71212094E+05  2.74475501E+05    4                              
  3.71143563E+05  2.74549000E+05    4                             
  3.70583906E+05  2.75149000E+05    4                              
  3.71711937E+05  2.74525999E+05    5                              
  3.71345345E+05  2.74919000E+05    5                             
  3.71192062E+05  2.75083501E+05    5                             
  3.71081063E+05  2.75202500E+05    5                              
  3.71866687E+05  2.74653501E+05    6                             
  3.71772937E+05  2.74753999E+05    6                           
  3.71434782E+05  2.75116500E+05    6                              
  3.71389439E+05  2.75165001E+05    6                              
  3.72380844E+05  2.74688500E+05    7                              
  3.72253031E+05  2.74825500E+05    7                           
  3.72159249E+05  2.74926000E+05    7                           
  3.72108063E+05  2.74981001E+05    7                              
  3.71860906E+05  2.75246001E+05    7                             
  3.71758376E+05  2.75356001E+05    7                             
  3.71761593E+05  2.74179500E+05    8                           
  3.71667875E+05  2.74280001E+05    8                              
  3.71463344E+05  2.74499500E+05    8                           
  3.71324187E+05  2.74648501E+05    8                           
  3.71204874E+05  2.74776501E+05    8                             
  3.71142376E+05  2.74843501E+05    8                           
  3.70951781E+05  2.75048000E+05    8                              
  3.71467632E+05  2.73614991E+05    9                              
  3.71271750E+05  2.73824999E+05    9                             
  3.71141219E+05  2.73965000E+05    9                             
  3.70936532E+05  2.74184501E+05    9                           
  3.70777188E+05  2.74355501E+05    9                              
  3.70598438E+05  2.74547001E+05    9                              
  3.70384970E+05  2.74776000E+05    9                             
  3.71759595E+05  2.74621500E+05   10                              
  3.71614531E+05  2.74777000E+05   10                             
  3.71543281E+05  2.74853502E+05   10                           
  3.71441187E+05  2.74962999E+05   10                             
  3.71378688E+05  2.75029999E+05   10                              
  3.71242126E+05  2.75176500E+05   10                              
  3.71922782E+05  2.74740000E+05   11                              
  3.71587375E+05  2.75099499E+05   11                              
  3.71394280E+05  2.75306500E+05   11                              
  3.71489657E+05  2.74324501E+05   12                              
  3.71404343E+05  2.74416000E+05   12                             
  3.71268156E+05  2.74562000E+05   12                             
  3.71148781E+05  2.74690000E+05   12                              
  3.71023750E+05  2.74823999E+05   12                              
  3.70801969E+05  2.75061999E+05   12                             
  3.70735468E+05  2.73667000E+05   13                             
  3.70587655E+05  2.73825499E+05   13                             
  3.70462688E+05  2.73959500E+05   13                             
  3.70300782E+05  2.74133000E+05   13                           
  3.69866033E+05  2.74599500E+05   13                              
  3.70873250E+05  2.73812500E+05   14                           
  3.70631720E+05  2.74071500E+05   14                             
  3.70481155E+05  2.74233001E+05   14                              
  3.71172812E+05  2.73784499E+05   15                              
  3.71036657E+05  2.73930501E+05   15                              
  3.70883249E+05  2.74095001E+05   15                              
  3.70704187E+05  2.74287000E+05   15                              
  3.70294969E+05  2.74726000E+05   15                              
  3.71250906E+05  2.73993999E+05   16                           
  3.71066344E+05  2.74191999E+05   16                             
  3.70850437E+05  2.74423499E+05   16                             
  3.70441219E+05  2.74862499E+05   16                             
  3.72004312E+05  2.74799000E+05   17                              
  3.71816874E+05  2.75000000E+05   17                              
  3.71527031E+05  2.75311000E+05   17                              
  3.71416218E+05  2.75429500E+05   17                              
  3.71604657E+05  2.74494500E+05   18                           
  3.71204061E+05  2.74924001E+05   18                              
  3.71129938E+05  2.75003500E+05   18                             
  3.71025000E+05  2.75116000E+05   18                             
  3.70325000E+05  2.73557500E+05   19                              
  3.70520124E+05  2.73739500E+05   19                              
  3.70678407E+05  2.73887001E+05   19                              
  3.70800281E+05  2.74000500E+05   19                             
  3.70922249E+05  2.74114499E+05   19                           
  3.71068655E+05  2.74251000E+05   19                           
  3.71178126E+05  2.74353001E+05   19                           
  3.71355000E+05  2.74517999E+05   19                           
  3.71513282E+05  2.74665500E+05   19                              
  3.71696094E+05  2.74836001E+05   19                             
  3.71945968E+05  2.75069000E+05   19                          
  3.70561875E+05  2.73505000E+05   20                           
  3.70982406E+05  2.73897000E+05   20                           
  3.71521781E+05  2.74399999E+05   20                              
  3.71850877E+05  2.74707000E+05   20                           
  3.72052001E+05  2.74894499E+05   20                              
  3.72066095E+05  2.75044500E+05   21                              
  3.71791812E+05  2.74788500E+05   21                              
  3.71499282E+05  2.74516000E+05   21                              
  3.70950782E+05  2.74004501E+05   21                           
  3.71804750E+05  2.75074001E+05   22                           
  3.71274500E+05  2.74579500E+05   22                             
  3.71030719E+05  2.74352501E+05   22                              
  3.71327031E+05  2.74059000E+05   23                              
  3.71122345E+05  2.74278500E+05   23                           
  3.70838311E+05  2.74583000E+05   23                             
  3.70673407E+05  2.74760000E+05   23                             
  3.70571219E+05  2.74869499E+05   23                             
  3.72074812E+05  2.74870000E+05   24                              
  3.71949720E+05  2.75004000E+05   24                              
  3.71762000E+05  2.75205499E+05   24                             
  3.71631407E+05  2.75345500E+05   24                           
  3.71815086E+05  2.73682008E+05   25                                
  3.71218469E+05  2.74321999E+05   25                              
  3.70954126E+05  2.74605500E+05   25                             
  3.70809156E+05  2.74760999E+05   25                              
  3.70578876E+05  2.75008001E+05   25                             
  3.71002875E+05  2.74736499E+05   26                             
  3.71106470E+05  2.74833000E+05   26                              
  3.71204001E+05  2.74923999E+05   26   
  3.71399061E+05  2.75106000E+05   26
搜索更多相关主题的帖子: 文本 数据 格式 
2008-09-18 15:45
puchengguo
Rank: 1
等 级:新手上路
帖 子:14
专家分:0
注 册:2008-9-18
收藏
得分:0 
转换后效果像这样,够明白了吧,谁会啊,发个代码过来吧
  3.71273374E+05  2.73530001E+05   1                              
  3.71210906E+05  2.73597001E+05   2                        
  3.71063093E+05  2.73755500E+05   2
  3.70972156E+05  2.73853001E+05   2                        
  3.70846875E+05  2.73987500E+05   2                        
  3.70665125E+05  2.74182499E+05   3                        
  3.70781905E+05  2.73470500E+05   1                              
  3.70483499E+05  2.73790500E+05   2                              
  3.70244719E+05  2.74046499E+05   2                              
  3.69827001E+05  2.74494501E+05   3                           
  3.70834406E+05  2.73707501E+05   1                             
  3.70615280E+05  2.73942501E+05   2                           
  3.70513156E+05  2.74052001E+05   2                             
  3.70399500E+05  2.74174000E+05   3                           
  3.71581376E+05  2.74079501E+05   1                           
  3.71496062E+05  2.74171000E+05   2                           
  3.71376687E+05  2.74299000E+05   2                              
  3.71212094E+05  2.74475501E+05   2                           
  3.71143563E+05  2.74549000E+05   2                           
  3.70583906E+05  2.75149000E+05   3                           
  3.71711937E+05  2.74525999E+05   1                          
  3.71345345E+05  2.74919000E+05   2                           
  3.71192062E+05  2.75083501E+05   2                           
  3.71081063E+05  2.75202500E+05   3                             
  3.71866687E+05  2.74653501E+05   1                           
  3.71772937E+05  2.74753999E+05   2                          
  3.71434782E+05  2.75116500E+05   2                             
  3.71389439E+05  2.75165001E+05   3                           
  3.72380844E+05  2.74688500E+05   1                             
  3.72253031E+05  2.74825500E+05   2                           
  3.72159249E+05  2.74926000E+05   2                           
  3.72108063E+05  2.74981001E+05   2                           
  3.71860906E+05  2.75246001E+05   2                           
  3.71758376E+05  2.75356001E+05   3                             
  3.71761593E+05  2.74179500E+05   1                          
  3.71667875E+05  2.74280001E+05   2                              
  3.71463344E+05  2.74499500E+05   2                             
  3.71324187E+05  2.74648501E+05   2                           
  3.71204874E+05  2.74776501E+05   2                              
  3.71142376E+05  2.74843501E+05   2                           
  3.70951781E+05  2.75048000E+05   3                             
  3.71467632E+05  2.73614991E+05   1                              
  3.71271750E+05  2.73824999E+05   2                              
  3.71141219E+05  2.73965000E+05   2                             
  3.70936532E+05  2.74184501E+05   2                             
  3.70777188E+05  2.74355501E+05   2                             
  3.70598438E+05  2.74547001E+05   2                              
  3.70384970E+05  2.74776000E+05   3                             
  3.71759595E+05  2.74621500E+05   1                              
  3.71614531E+05  2.74777000E+05   2                             
  3.71543281E+05  2.74853502E+05   2                           
  3.71441187E+05  2.74962999E+05   2                             
  3.71378688E+05  2.75029999E+05   2                              
  3.71242126E+05  2.75176500E+05   3                              
  3.71922782E+05  2.74740000E+05   1                             
  3.71587375E+05  2.75099499E+05   2                              
  3.71394280E+05  2.75306500E+05   3                             
  3.71489657E+05  2.74324501E+05   1                              
  3.71404343E+05  2.74416000E+05   2                             
  3.71268156E+05  2.74562000E+05   2                             
  3.71148781E+05  2.74690000E+05   2                              
  3.71023750E+05  2.74823999E+05   2                              
  3.70801969E+05  2.75061999E+05   3                           
  3.70735468E+05  2.73667000E+05   1                             
  3.70587655E+05  2.73825499E+05   2                           
  3.70462688E+05  2.73959500E+05   2                           
  3.70300782E+05  2.74133000E+05   2                           
  3.69866033E+05  2.74599500E+05   3                              
  3.70873250E+05  2.73812500E+05   1                           
  3.70631720E+05  2.74071500E+05   2                             
  3.70481155E+05  2.74233001E+05   3                              
  3.71172812E+05  2.73784499E+05   1                              
  3.71036657E+05  2.73930501E+05   2                              
  3.70883249E+05  2.74095001E+05   2                             
  3.70704187E+05  2.74287000E+05   2                             
  3.70294969E+05  2.74726000E+05   3                             
  3.71250906E+05  2.73993999E+05   1                          
  3.71066344E+05  2.74191999E+05   2                             
  3.70850437E+05  2.74423499E+05   2                           
  3.70441219E+05  2.74862499E+05   3                           
  3.72004312E+05  2.74799000E+05   1                              
  3.71816874E+05  2.75000000E+05   2                           
  3.71527031E+05  2.75311000E+05   2                             
  3.71416218E+05  2.75429500E+05   3                             
  3.71604657E+05  2.74494500E+05   1                          
  3.71204061E+05  2.74924001E+05   2                             
  3.71129938E+05  2.75003500E+05   2                          
  3.71025000E+05  2.75116000E+05   3                             
  3.70325000E+05  2.73557500E+05   1                           
  3.70520124E+05  2.73739500E+05   2                             
  3.70678407E+05  2.73887001E+05   2                              
  3.70800281E+05  2.74000500E+05   2                             
  3.70922249E+05  2.74114499E+05   2                          
  3.71068655E+05  2.74251000E+05   2                           
  3.71178126E+05  2.74353001E+05   2                           
  3.71355000E+05  2.74517999E+05   2                           
  3.71513282E+05  2.74665500E+05   2                              
  3.71696094E+05  2.74836001E+05   2                             
  3.71945968E+05  2.75069000E+05   3                        
  3.70561875E+05  2.73505000E+05   1                  
  3.70982406E+05  2.73897000E+05   2                           
  3.71521781E+05  2.74399999E+05   2                             
  3.71850877E+05  2.74707000E+05   2                          
  3.72052001E+05  2.74894499E+05   3                           
  3.72066095E+05  2.75044500E+05   1                           
  3.71791812E+05  2.74788500E+05   2                           
  3.71499282E+05  2.74516000E+05   2                              
  3.70950782E+05  2.74004501E+05   3                     
  3.71804750E+05  2.75074001E+05   1                           
  3.71274500E+05  2.74579500E+05   2                           
  3.71030719E+05  2.74352501E+05   3                          
  3.71327031E+05  2.74059000E+05   1                              
  3.71122345E+05  2.74278500E+05   2                           
  3.70838311E+05  2.74583000E+05   2                             
  3.70673407E+05  2.74760000E+05   2                             
  3.70571219E+05  2.74869499E+05   3                             
  3.72074812E+05  2.74870000E+05   1                             
  3.71949720E+05  2.75004000E+05   2                           
  3.71762000E+05  2.75205499E+05   2                           
  3.71631407E+05  2.75345500E+05   3                           
  3.71815086E+05  2.73682008E+05   1                              
  3.71218469E+05  2.74321999E+05   2                           
  3.70954126E+05  2.74605500E+05   2                          
  3.70809156E+05  2.74760999E+05   2                              
  3.70578876E+05  2.75008001E+05   3                             
  3.71002875E+05  2.74736499E+05   1                             
  3.71106470E+05  2.74833000E+05   2                              
  3.71204001E+05  2.74923999E+05   2   
  3.71399061E+05  2.75106000E+05   3

[[it] 本帖最后由 puchengguo 于 2008-9-19 15:32 编辑 [/it]]
2008-09-19 15:19
puchengguo
Rank: 1
等 级:新手上路
帖 子:14
专家分:0
注 册:2008-9-18
收藏
得分:0 
第1列和第2列不变。  就第3列变了, 它的意思是把相同的数据改为:
首尾是 1和3 ,中间是 2 的形式哇哇。
2008-09-20 11:47
快速回复:文本格式中数据转换问题
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.034469 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved