Python - merging of csv files with one axis in common
Question: I need to merge two csv files, `A.csv` and `B.csv`, with one axis in common,
extract:

    
    
    9.358,3.0
    9.388,2.0
    

and

    
    
    8.551,2.0
    8.638,2.0
    

I want the final file C.csv to have the following pattern:

    
    
    8.551,0.0,2.0
    8.638,0.0,2.0
    9.358,3.0,0.0
    9.388,2.0,0.0
    

How to you suggest to do it? Should I go for a for loop?


Answer: 
    import numpy as np
    
    dat1 = np.genfromtxt('dat1.txt', delimiter=',')
    dat2 = np.genfromtxt('dat2.txt', delimiter=',')
    
    dat1 = np.insert(dat1, 2, 0, axis=1)
    dat2 = np.insert(dat2, 1, 0, axis=1)
    
    dat = np.vstack((dat1, dat2))
    
    np.savetxt('dat.txt', dat, delimiter=',', fmt='%.3f')
    

