python 2.7 - How can I match 2 file csv? -
file 1 column: id name city work row: 123 mark chicago baker file 2 column: id name work age row: 123 mark baker 27
i want match 2 file adding @ output column "age".
file output column: id name city work age row: 123 mark chicago baker 27
can me, please?
you can use pandas
library this
import pandas def main(): file1 = pandas.read_csv("file1.csv") file2 = pandas.read_csv("file2.csv") file2 = file2.dropna(axis=1) output = file1.merge(file2, on='id') output.to_csv("output.csv", index=false) if __name__ == "__main__": main()
hope (y).
Comments
Post a Comment