本文介绍了从文本文件中提取数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
限时送ChatGPT账号..我有一个像这样开头的文本文件:
<块引用>[详情]版本=100开关=340视频=800日期=20100912长度=00:49:34.2天数=1小时=20
有没有一种方法可以检查 [Details]
部分中的每一行,然后执行类似的操作?
if(line == "version"){//读取整数 100}
文本文件中还有我不感兴趣的其他文本.我只需要找到[Details]
部分.
using (StreamReader sr = new StreamReader(path)){而 (sr.Peek() >= 0){var keyPair = sr.ReadLine();var key = keyPair.Split('=')[0];var value = keyPair.Split('=')[1];}}
I have a text file that starts like this:
[Details] Version=100 Switch=340 Video=800 Date=20100912 Length=00:49:34.2 Days=1 hours=20
Is there a way that I can check each line within the [Details]
section and then do something like this?
if(line == "version")
{
// read the int 100
}
Also there is other text in the text file that is of no interest to me. I only need to find the [Details]
part.
using (StreamReader sr = new StreamReader(path))
{
while (sr.Peek() >= 0)
{
var keyPair = sr.ReadLine();
var key = keyPair.Split('=')[0];
var value = keyPair.Split('=')[1];
}
}
这篇关于从文本文件中提取数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
更多推荐
[db:关键词]
发布评论