从文件行中提取数据 [英] extract the data from line in file

查看:88
本文介绍了从文件行中提取数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个文件,这个文件包含这样的行: -



KeyValue = 45AD34 NumberOfPages = 2

KeyValue = 33AD46 NumberOfPages = 1



i只想在向量中放入数值。请告诉我

I have one file and this file contain line like this :-

KeyValue=45AD34 NumberOfPages=2
KeyValue=33AD46 NumberOfPages=1

i want to put only numeric value in vector. plz tell me

推荐答案

使用字符串标记方法从那里找出''=''符号,直到某些数据长度移入vector.if你需要任何澄清意愿进一步检查。
use string tokenize method to find out the ''='' symbol from there upto some data length move into vector.if u need any clarification will check it further.


阅读 <$ c $上的文档c> string class [ ^ ]。它提供了许多用于对字符串进行操作的有用函数。
Read the documentation on the string class[^]. It provides many useful functions for manilulating character strings.


如果你的文件格式非常简单(即固定长度字段),你可以轻松地(逐行处理)提取子字符串(基于在他们感兴趣的线上的位置,然后将它们添加到矢量。
If your file format is really that simple (that is fixed length fields) you may easily (processing line by line) extract the substrings (based on their position inside the line) of interest and then add them to the vector.


这篇关于从文件行中提取数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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