合并和匹配.NET 2 CSV文件文件、NET、CSV

2023-09-06 23:10:55 作者:枯坐酒灯明

我已经得到了我想要合并两个的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"