Hello,
I have two .csv files as below:
.csv1
POS,ID
28000167,.
28000263,.
28000484,.
28000711,.
28000728,.
28000885,.
28089922,.
28089927,.
28090173,.
28090325,.
28090326,.
28090331,.
28090415,.
28090467,.
28096247,.
28096264,.
28096284,.
.csv2
POS,ID
28000167,rs75043266
28000263,rs151210258
28000484,rs7175266
28000627,.
28000711,.
28000728,rs140405700
28000885,.
28089732,.
28089847,.
28089876,.
28089898,.
28089922,rs12592271
28089927,rs113937352
28090008,.
28090173,rs12592307
28090325,rs187389297
28090326,rs74005248
28090331,rs113905655
I would like to update the values of the row [1] of the .csv1 file with the values of row [1] of the .csv2 files if row [0] of .csv1 is present in row [0] of .csv2. / p>
In this case my .csv1 file would become as:
.csv1
POS,ID
28000167,rs75043266
and so on for all the other iterations he finds ...
What I have so far of code is not much since I could not get any iteration ...
import csv
csv1 = open("arquivo1.csv")
reader1 = csv.reader(csv1, dialect='excel-tab')
csv2 = open("arquivo2.csv")
reader2 = csv.reader(csv2, dialect='excel-tab')
next(reader1, None)
for row1 in reader1:
next(reader2, None)
for row2 in reader2:
Any help would be welcome! Thank you.