阅读文本文件并获取特定的搅拌填充日期 [英] Read a Text File and get the Specific stirng padded Date

查看:74
本文介绍了阅读文本文件并获取特定的搅拌填充日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,

首先,我要感谢那些在我最近的两个问题中帮助过我的人。我已经把它们结束了,现在没关系。但是,我正在开发一个项目来读取几个文本文件,验证它们并处理它们以使其与另一个系统进行处理,以便我定期发布帮助。所以,谢谢你们帮助像我这样的中级程序员的代码大师。



我的下一个问题是,我有一个文本文件。它有标题字符串,右键。我想要的是读取文本文件并在标题上选择日期。标题详情如下。



H100 FileName日期官员测试

jhashdjha ajshdja ahdjahdjahjdh hadjhdjahdjs aj hdja



H100 -is Padded Right 9,FileName - 填充右12,日期 - 填充右10,官员 - 填充右12,测试 - 填充右4.



标题后面显然有其他文字。请协助从标题中获取日期。我已经在网上搜索了,因此我无法快速抓住这些东西,所以我在问。



提前感谢。

Hello,
Firstly I just want to thank those who have assisted me in my 2 recent questions. I have got them over and it''s okay now. However, I''m working on a project to read several text files, validate them and process them to align it for processing by another system so I''ll post for assistance regularly. So thank you to the code gurus who are assisting such intermediate programmers like me.

My next issue is, I have a text file. It has header strings which are rightpadded. What I want is to read the text file and pick up the date on the header. The header details are as follows.

H100 FileName Date Officer Test
jhashdjha ajshdja ahdjahdjahjdh hadjhdjahdjs aj hdja

H100 -is Padded Right 9, FileName - is padded Right 12, Date - is padded right 10, Officer - is padded right 12 and tes - is padded right 4.

After the header there are obviously other texts. Please assist to grab the Date from the header. I have searched the web adn couldn''t grab something in line to this quickly so I''m asking.

Thanking in advance.

推荐答案

所以你要解析一行固定宽度的字段......读取行,进入前9个字符并存储在H100中,接下来的12个字符并存储在FileName中,继续直到消耗掉所有字符。



然后,使用存储数据的变量来完成你需要的任何任务。



MSDN - 如何从文本文件中读取 [ ^ ]



可以帮助您的其他功能:左,右,中,instr
So you are parsing a line of fixed width fields... Read the line in, take the first nine chars and store in H100, take the next 12 chars and store in FileName, continue until you have consumed all chars.

Then, use the variables that you have stored the data in for whatever tasks you need them for.

MSDN - How to read from a text file [^]

Other functions that will help you: left, right, mid, instr


这篇关于阅读文本文件并获取特定的搅拌填充日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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