这应该是一个简单的,但我是C#的初学者。
给出以下格式的词汇表:
aptitude ability, skill, gift, talent aqueous watery arguably maybe, perhaps, possibly, could be我该如何解析它,并以以下格式插入数据库表:
TABLE: Term_Glossary ================================================ Term_Name | Term_Definition | ================================================ aptitude | ability, skill, gift, talent | ------------------------------------------------ aqueous | watery | ------------------------------------------------ arguably | maybe, perhaps, possibly, could be| ================================================任何帮助将不胜感激 - 谢谢。
更新我意识到数据库结构简单/低效 - 但实际上,我的问题是使用C# 解析第一个示例中找到的文本类型的代码 。 谢谢。
This should be a simple one, but I'm a beginner with C#.
Given a glossary list in the following format:
aptitude ability, skill, gift, talent aqueous watery arguably maybe, perhaps, possibly, could beHow can I parse this, and insert into a database table in the format:
TABLE: Term_Glossary ================================================ Term_Name | Term_Definition | ================================================ aptitude | ability, skill, gift, talent | ------------------------------------------------ aqueous | watery | ------------------------------------------------ arguably | maybe, perhaps, possibly, could be| ================================================Any help would be appreciated - thanks.
Update I realize the database structure is simple/inefficient - but really, the point of my question is the code to parse the kind of text found in the first example, using C#. Thanks.
最满意答案
在我看来,你会读取第一行,将其保存到变量,读取第二行,将其保存到第二个变量,然后插入表中Term_Name =第一个变量,以及Term_Definition =第二个变量。
所以你的逻辑就像:
StreamReader SR; string Term_Name; string Term_Definition SR = File.OpenText(filename); Term_Name = SR.ReadLine(); while(Term_Name != null) { Term_Definition = SR.ReadLine(); // make your database call here to insert with these two variables. I don't know what DB you are using. Term_Name = SR.ReadLine(); } SR.Close();It looks to me like you would read the first line, save it to a variable, read the second line, save it to a second variable, then insert into the table where Term_Name = first variable, and Term_Definition = second variable.
So your logic would be like:
StreamReader SR; string Term_Name; string Term_Definition SR = File.OpenText(filename); Term_Name = SR.ReadLine(); while(Term_Name != null) { Term_Definition = SR.ReadLine(); // make your database call here to insert with these two variables. I don't know what DB you are using. Term_Name = SR.ReadLine(); } SR.Close();更多推荐
发布评论