내 스크립트로 솔루션을 얻으려면 도움이 필요합니다. 두 개의 배열로 값 바꾸기 numpy
나는 두 배열을 가지고 :==> 첫 번째는 code_client
라는 1 열을 얻는다. 파일 이름은 excel.txt
입니다. ==> 두 번째 열은 rowid
및 code_client
의 두 열이 있습니다. 우리는 파일을 BDD.txt
이라고 부를 것입니다.
첫 번째 파일에서 두 번째 파일과 관련된 rowid 값을 바꾸고 싶습니다.
code_client
208
1643
1595
2607
2608
2470
1547
481
226
558
두 번째 파일이 보이는 같은 : 내가 값을 연결할 수 있습니다 방법을 모르는
# 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'
:
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
이 내 스크립트처럼
먼저 파일을 찾습니다 . excel file
에서 행을 읽고 BDD file
과 비교해야한다고 생각합니다. 에서 BDD file
으로 동일한 번호를 얻은 경우 을 excel file
에서 으로 바꿉니다. 그렇지 않으면 계속하겠습니다.
도움이 될까요?
감사합니다.
편집 : 예상 된 FILE
첫 번째 파일이되고 있습니다
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
첫 번째 파일에'list '행이 있고'index_ 1'과 동일한'row_id'가 아니라면 그냥 호출 할 수 있습니다 'list [row_id - 1] = new_value' –
샘플의 예상 출력은 얼마입니까? – Divakar
@btquanto 첫 번째 파일이 오름차순으로 정렬되지 않았으므로 아니요. 나는이 명령서를 지켜야한다. 또한, rowid = 1,2,3 ... 및 code_client = 1,2,4 등. 끝에서 rowid = 2800 및 code_client = 3600 – Deadpool