合并和匹配.NET 2 CSV文件 [英] merge and match two csv files with .net

查看:121
本文介绍了合并和匹配.NET 2 CSV文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经得到了我想要合并两个的CSV文件。基本上,我有我的源文件,第二个文件将使用一个主键信息添加到该文件,它们都共享。

i've got two csv files that i want to merge. Basically, i've got my source file, and the second file will add information to that file using a primary key that they both share.

我做这个使用V-查找,但由于这将是一个每周一次的过程中,我想用vb.net或C#来自动执行它。任何想法?

I've done this using v-lookup but since this will be a weekly process, i want to automate it using vb.net or C#. any ideas?

感谢

推荐答案

这是很可能使用SQL和CSV文件在任何vb.net或C#。

It is quite possible to use SQL with CSV files in either vb.net or c#.

一些注意事项:

cn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
            "Data Source=c:\docs\;" & _
            "Extended Properties=""text;HDR=Yes;FMT=Delimited"""
cn.Open()

cmd.Connection = cn
cmd.CommandType = CommandType.Text
cmd.CommandText = "SELECT a.PK, b.SText,a.[Processor Time] INTO BookX.csv " & _
            "FROM [Book1.CSV] a " & _
            "LEFT JOIN [Book2.CSV] b " & _
            "ON a.PK = b.PK"

这篇关于合并和匹配.NET 2 CSV文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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