請求入金
請求入金 マッチング 文字列の揺らぎがある場合、ベクトルデータを使ったマッチングは非常に有効です。 具体的には、文字列の類似度を計算するために、自然言語処理(NLP)の技術を利用することができます。 以下は、fuzzywuzzyライブラリを使用して文字列の類似度を計算し、マッチングを行うサンプルコードです: まず、必要なライブラリをインストールします: 1 pip install pandas openpyxl fuzzywuzzy 次に、サンプルコードです: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 import pandas as pd from fuzzywuzzy import fuzz # 入金リストと請求明細のファイルパス payments_file = 'payments.xlsx' invoices_file = 'invoices.xlsx' # Excelファイルからデータを読み込む payments_df = pd.read_excel(payments_file) invoices_df = pd.read_excel(invoices_file) # 類似度の閾値を設定 similarity_threshold = 80 # マッチング結果を格納するリスト matched_records = [] # 入金リストと請求明細をマッチングさせる for _, payment in payments_df.iterrows(): for _, invoice in invoices_df.iterrows(): # 金額が一致するか確認 if payment['金額'] == invoice['請求金額']: # 振り込み依頼人と顧客名の類似度を計算 similarity = fuzz.token_sort_ratio(payment['振り込み依頼人'], invoice['顧客名']) if similarity >= similarity_threshold: matched_records.append({ '入金ID': payment['入金ID'], '請求ID': invoice['請求ID'], '金額': payment['金額'], '振り込み依頼人': payment['振り込み依頼人'], '顧客名': invoice['顧客名'], '類似度': similarity }) # マッチング結果をデータフレームに変換 matched_df = pd.DataFrame(matched_records) # マッチング結果を表示 print(matched_df) # マッチング結果を新しいExcelファイルに保存 matched_df.to_excel('matched_results.xlsx', index=False) このコードでは、以下の手順を実行しています: ...