且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用时间戳合并csv文件

更新时间:2023-10-26 14:46:10

您可以使用Python Pandas轻松完成此操作,但这可能是过度设计:

You could use Python Pandas to do this quite easily, but its probably an overengineering:

import pandas as pd
d_one = from_csv('data.csv',sep=',',engine='python',header=0)
d_two = from_csv('data2.csv',sep=',',engine='python',header=0)
d_three = pd.merge(d_one, d_two, left_on='timestamp',right_on='timestamp')
d_three.to_csv('output.csv',sep=',')

我还没有机会测试此代码,但是它应该做您想要的,您可能需要修改制表符的逗号(取决于文件),等等.

I havent had the chance to test this code but it should do what you want, you may need to modify commas for tabs (depending on the file), etc.