如何对文本文件执行类似简单SQL的操作 [英] How to do simple SQL like operation on a text file

查看:194
本文介绍了如何对文本文件执行类似简单SQL的操作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好

我有一个dbase.txt文件,其中包含一些数据.即-

院校课程StudentID
XZY ABC 2010-1111111列之间的空间是一个制表符空间"
XYZ ABC 2010-1222222
XYZ ABC 2010-1333333

我想执行简单的SQL之类的操作-即-

选择* FROM dbase.txt或
在dbase.txt中选择SELECT机构,其中WHERE StudentID = 2010-1111111和类似-
的插入操作 插入dbase.txt值(XYZ ABC 2010-1444444)

我已经编写了一些代码,这些代码与我上面提到的代码甚至还不一样.我的程序只能读取整个文本文件.有一个菜单,但不能很好地工作,还有我的写功能根本无法正常工作.

因此,任何人都可以帮助我解决这个问题.指向任何网站的任何链接也将有所帮助.以下是我的代码-

预先感谢.

Hi all

I have a dbase.txt file with some data in it. i.e -

Institution Course StudentID
XZY ABC 2010-1111111 "the spaces between columns is one tab space"
XYZ ABC 2010-1222222
XYZ ABC 2010-1333333

I want to perform simple SQL like operation - i.e -

SELECT * FROM dbase.txt or
SELECT Institution FROM dbase.txt WHERE StudentID=2010-1111111 and an insert operation like -
INSERT dbase.txt VALUES(XYZ ABC 2010-1444444)

I have written some code which is not even closer to what I mentioned above. My program can read only the whole text file. There is a menu, but not functioning well, as well as my write function which is not working at all.

So, can anyone help me with this problem. Any link to any web site would also be helpful. Below is my code -

Thanks in advance.

推荐答案

好吧,开发数据库引擎是一项艰巨的任务...
:)
Well, you know, developing a database engine is a daunting task...
:)


首先,您将不得不将数据加载到列表中.此时,您可以使用Linq在列表上执行类似sql的查询.
First, you''re going to have to load the data into a list. At that point, you can use Linq to perform sql-like queries on the list.


这篇关于如何对文本文件执行类似简单SQL的操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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