读取文本文件并填写地图文件 [英] Read a text file and fill the map file

查看:69
本文介绍了读取文本文件并填写地图文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

HI,

我有如下文本文件

名称="AA",DOB ="01/jan",地址=印度"
名称="BB",DOB ="01/jan",地址=印度"
Name ="CC",DOB ="01/Feb",Address ="India",Mobile ="XXXX"
Name ="DD",DOB ="01/Mar",Address ="India",Mobile ="XXXX"

我想阅读以上文件并填写地图.
任何人都可以通过一个好主意对此提供帮助.

在此先谢谢您.



I have the text file as follows

Name="AA",DOB="01/jan",Address="India"
Name="BB",DOB="01/jan",Address="India"
Name="CC",DOB="01/Feb",Address="India",Mobile="XXXX"
Name="DD",DOB="01/Mar",Address="India",Mobile="XXXX"

i want to read the above file and fill the map.
Can any one help in this with good idea.

Thanks in advance.

推荐答案

您好,Durga_Devi,

考虑到论坛的规则(以及其他论坛),我们无法为您提供所有代码,因为它将被视为完成某人的功课.

因此,这里链接 [
Hi Durga_Devi,

Considering the forum''s rules (as well the other forums too) we couldn''t give you all the code coz it will be considered as doing somebody homework.

So here a link [^] for a good tutorial which may help you with your request (you may declare your map as follow map< string, string> dB;.

Good luck.


解析起来既简单又方便:
每一行都保存一个信息.这可能以\ r \ n或只是\ r结尾,无法确定答案.每行有多个数据,它们的长度是可变的,并且用逗号分隔.每个字段都有两部分,类型和数据,数据用."括起来.

步骤1:
读取每个字节,直到找到行尾;

第2步:在这里行了
现在,您可以创建一个二维数组来保存单独的数据.可以采用多种方式.

步骤3:
填写地图

步骤4:
转到步骤1
The parsing would be fare and simple:
Every line Hold one information. This one probably end with \r\n or just \r, not possible to answer surely. Every line has more than one data, with variable length, and they are separated by comma. and every field has two part Type and data and data is enclosed by ".

Step 1:
Read every byte until you find end of line;

Step 2: here you have go a line
Now, you can create a two dimension array to hold separate the data. Various way can be applied for this.

Step 3:
Fill the map

Step 4:
Go to Step 1


这篇关于读取文本文件并填写地图文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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