kanekunのメモ

AIが作ったプログラムのバックアップ

2024-01-01から1ヶ月間の記事一覧

正規表現

/\/[0-9]+\/(?!.*\/\/)/ \/[0-9]+\/[0-9]+\/$ /(.*?)\/(.*?)\/.*/ ^\/\d+\/(\d+\/)*$ const input = `/00001/00001/00002/`;const regex = /(\d+)\//g;const result = input.replace(regex, '$1');console.log(result); // => '/00001/' (?<=/)(.+?)(?=/) /0…

CSV比較(Bing)

import pandas as pdimport sys def compare_csv_files(file1, file2): # Read CSV files df1 = pd.read_csv(file1, usecols=[0, 1, 3], header=None) df2 = pd.read_csv(file2, usecols=[0, 1, 3], header=None) # Compare CSV files diff = pd.concat([df1…

JSONを扱う(Gemini Pro)

import csvimport json # JSONファイルを読み込むwith open(引数1, 'r') as f: json_data = json.load(f) # CSVファイルを読み込むwith open(引数2, 'r') as f: csv_reader = csv.reader(f) csv_data = list(csv_reader) # JSONファイルとCSVファイルを突…

CSVファイルの突合(ChatGPT)

import csv def filter_csv(file1, file2, output_file): """ Reads two CSV files and writes the rows from the first file to the output file where the first column matches between the two files. """ # Read the first column from the second file…

SQLのテスト3

○ChatGPT SELECT COALESCE(t1.field1, t2.field1) AS field1, COALESCE(t1.field2, t2.field2) AS field2FROM table1 t1FULL OUTER JOIN table2 t2ON t1.field1 = t2.field1 AND t1.field2 = t2.field2WHERE (t1.field2 IS NULL OR t2.field2 IS NULL)AND (t…

SQLのテスト2

ChatGPT SELECT *FROM table1FULL OUTER JOIN table2ON table1.field1 = table2.field1 AND table1.field2 = table2.field2WHERE table1.field1 IS NULL OR table2.field1 IS NULL; Claude2 SELECT t1.field1, t1.field2 FROM table1 t1LEFT JOIN table2 t2O…

SQLのテスト

○chatgpt SELECT t1.field1, t1.field2FROM table1 t1LEFT JOIN table2 t2 ON t1.field1 = t2.field1WHERE t1.field2 <> t2.field2 OR t2.field2 IS NULL; ○claude2 SELECT t1.field1, t1.field2 FROM table1 t1LEFT JOIN table2 t2 ON t1.field1 = t2.field…

JSON抽出(Claude2)

import jsonimport sys # JSONファイルのパスjson_file = sys.argv[1] # orgpathの抽出条件target_orgpath = sys.argv[2] # JSONファイルを開くwith open(json_file) as f: data = json.load(f) # usrListから条件にマッチするデータを抽出result = []for us…

VBA(Gemini Pro)

Sub JSONtoCell() Dim objJSON Dim strData ' JSONファイルを開く Open "C:\Sample.json" For Input As #1 ' JSONデータを読み込む strData = Input$(LOF(1), #1) Close #1 ' JSONデータをパースする Set objJSON = JsonConverter.ParseJson(strData) ' JSON…

REST API VBA(Claude2)

' クライアントIDとクライアントシークレットの設定Const client_id = "****************************"Const client_secret = "********************************" ' トークンエンドポイントConst token_url = "https://XXX" ' アクセストークンを取得Functi…

バッチファイル(ChatGPT)

@echo off REM ログインエンドポイントと認証情報set LOGIN_ENDPOINT=https://example.com/api/loginset USERNAME=your_usernameset PASSWORD=your_password REM セッションIDを取得for /f "tokens=*" %%i in ('curl -s -X POST "%LOGIN_ENDPOINT%" -d "user…

REST API(ChatGPT)

# 設定$baseUrl = "https://example.com/api" # APIのベースURL$username = "your_username" # ユーザー名$password = "your_password" # パスワード$loginUrl = "$baseUrl/login"$triggersUrl = "$baseUrl/triggers"$logoutUrl = "$baseUrl/logout" # ヘル…

REST API(Perplexity)

# ログイン$loginUrl = "https://example.com/login"$loginBody = @{ username = "your_username" password = "your_password"}$loginResponse = Invoke-RestMethod -Method Post -Uri $loginUrl -Body $loginBody$authToken = $loginResponse.auth_token # …