简体   繁体   中英

Adding column from one CSV file to another CSV file

I have 2 CSV files that I need to merge together based on a key i created ( the purpose was to mask ID's then join the ids on the key later ) I can do this in SSIS, but im have an error runing the batch script from my python script (something to do with SSIS not running packages outside SSIS. Working with software team to fix ) but in the mean time I would like to just have it working for a demo.

Is this possible in Python?

File 1:
input_id multiple columns --->
1
2
3
File 2:
input_id  ID
1         1234
2         1235
3         1236

output:
input_id multiple columns ---> ID
1                              1234
2                              1235
3                              1236 
a = pd.read_csv("import.csv")

b = pd.read_csv("entity_ids.csv")

merge = a.merge(b, how='left', on='input_id')

merge.to_csv("test2.csv", index = False)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM