I need your help in order to get a solution with my script.
I have 2 arrays :
==> The first one get 1 column which is named code_client. We will call the file : excel.txt.
==> The second one has 2 columns : rowidand code_client. We will call the file : BDD.txt.
I would like to replace in the first file the value by rowid associated with the second file.
First file looks like :
code_client
208
1643
1595
2607
2608
2470
1547
481
226
558
Second file looks like :
rowid,code_client
1,1
2,2
3,4
4,5
5,6
6,7
7,8
8,9
9,10
10,11
11,12
12,13
13,14
14,15
This is my script :
# Script permettant de remplacer le code_client par le rowid de la BDD
# coding: utf8
import numpy as np
# Importation du fichier excel
excel = np.loadtxt('/Users/valentinjungbluth/Desktop/excel.txt',
dtype = int)
#print excel
BDD = np.genfromtxt('/Users/valentinjungbluth/Desktop/BDD.txt',
dtype = [('rowid','i8'),('code_client','i8')],
delimiter = ',')
for row1 in excel :
if excel == BDD['code_client'] :
print 'oui'
else :
print 'non'
I don't know how I can associate values. I think I have to read rows from the excel file and compare with the BDD file. If I get the same number between code_client from excel file with BDD file, I replace code_client from excel file by rowid from BDD.file. Else I continue.
Is it possible to get some help ?
Thank you !
EDIT : EXPECTED FILE
The first file have to become :
code_client ==> rowid
208 ==> this code_client in the second file gives rowid = 183
1643 ==> this code_client in the second file gives rowid = 1498
1595 ==> ...
2607
2608
2470
1547
481
226
558
listof rows in the first file, isn't therow_idthe same asindex + 1, you can just calllist[row_id - 1] = new_value