loop through rows of one csv file to find corresponding data in another

后端 未结 3 1881

I got an interesting problem:

file1.csv has a few hundred rows like:

Code,DTime
1,2010-12-26 17:01
2,2010-12-26 17:07
2,2010-12-26 17:15
3条回答
  •  生来不讨喜
    2020-12-06 21:08

    Unless you only need to do this once, you should really use a database. Add a column to table2 that contains DATETIME without the seconds, so that you can join on exact matches, not with LIKE.

    It WILL be fast, and even faster if you index those columns. And if you can store file1.csv in the database too, you don't need iterations: You can get the entire set of results in a single select query. This is the kind of stuff SQL is made for.

    PS. If you decide to pursue this approach, you can ask for help with the query.

提交回复
热议问题