搜索文件中的特定字段[VB.NET] [英] Search a particular field in a file [VB.NET]

查看:56
本文介绍了搜索文件中的特定字段[VB.NET]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,我有一个包含大量数据的大型.csv文件。我想使用特定字段查看此文件。



例如,我的文件看起来有点像这样:location;公司;产品代码,部门,成本,价格



所以我想尝试使用产品代码,如果找到它,就需要整行,然后出现。



如果我有一个看起来像这样的文件。



左墙;沃尔玛; 0000 0001;电子; 7.99; 9.99;

右墙百事可乐; 8883 0012;餐饮; 0.01; 3.99;

上限;市民防办; 9981 0011;餐饮; 0.05; 1.99;



因此,如果我搜索产品代码0000 0001,它将显示左墙,沃尔玛,0000 0001电子版7.99 9.99



直接在文件中搜索或用字符串传输并在其中搜索是否更好?



所以是的,如果有人有一个链接或算法,非常感谢!



谢谢你们!



我尝试了什么:



我在google上尝试了很多搜索,但没找到我正在寻找的东西!

Hi guys, i have a large .csv file that contains a lot of Data. I would like to look into this file using a particular field.

For example, my file looks a bit like this: location; company; product code, department, cost, price

So Id like to try with the product code, and if it finds it, it takes the entire line and he appears.

So if I have a file that looks like this.

left wall; wal-mart; 0000 0001; electronic; 7.99; 9.99;
right wall pepsi; 8883 0012; food; 0.01; 3.99;
upper; mcdo; 9981 0011; food; 0.05; 1.99;

So if I search for the product code 0000 0001 it will display left wall, wal-mart, 0000 0001 Electronic 7.99 9.99

Is it better to search directly in the file or transfer it in a string and search in it?

So yeah, if anyone have a link or a algorithm it would be very appreciated!

Thank you guys!

What I have tried:

I try a lot of search on google and didn't find what im looking for!

推荐答案

以上都没有!在分隔文本文件中搜索数据的最快方法是使用 OleDb [ ^ ]。



查看:

阅读文本文件(txt,csv,log,tab,固定长度) [ ^ ]

读取文本文件特定列 [ ^ ] - 完成,正常工作代码!



详情请见:

关于文本文件的大量ADO [ ^ ]

Schema.ini文件(文本文件驱动程序) [ ^ ]

ADO.NET概述 [ ^ ]



试试吧!祝你好运!
None of above! The fastest way to search data in delimited text files is to use OleDb[^].

Check this:
Read Text File (txt, csv, log, tab, fixed length)[^]
Read Text File Specific Columns[^] - complete, working code!

For further details, please see:
Much ADO About Text Files[^]
Schema.ini File (Text File Driver)[^]
ADO.NET Overview[^]

Try! Good luck!


2种可能性

- 你有多项研究要做:

在内存中加载文件会占用大量空间但是会在第一个之后加速研究。

像解决方案1这样复杂的处理将花费时间处理文件并节省每次搜索的时间。



- 您只需进行一次搜索:

一次加载文件会占用大量内存,但由于您只搜索一次,因此无法节省时间。
$ b逐行加载$ b将占用较小的内存,与加载整个文件的速度大致相同。

对于单个搜索,简单的粗暴力就是最好的。
2 possibilities
- you have multiple researches to do:
loading the file in memory will make a large footprint, but will speedup researches after the first one.
A sophisticated handling like in Solution 1 will spend time when handling the file and save time with every search.

- you have a single search to do:
loading the file at once will have a large memory footprint but will not save time because you search only once.
loading line by line will have a small memory footprint will about same speed as loading the whole file.
For a single search, simple brut force is about the best.

这篇关于搜索文件中的特定字段[VB.NET]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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