We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
非常感谢提供详尽的数据。 我写了一段python代码,可以提取目录中型号以及手机名称对应关系,生成sql语句到数据库中,方便大家使用。
import os # 定义目录路径 directory_path = 'D:\\project\\github\\MobileModels\\brands' # 替换成你的md文件目录路径 output_file = os.path.join(directory_path, 'insert.sql') # 存储匹配结果 matches = [] # 打开日志文件 log_file_path = os.path.join(directory_path, 'processing.log') with open(log_file_path, 'w', encoding='utf-8') as log_file: # 遍历目录中的所有md文件 for filename in os.listdir(directory_path): if filename.endswith('.md'): log_file.write(f'Processing file: {filename}\n') print(f'Processing file: {filename}') with open(os.path.join(directory_path, filename), 'r', encoding='utf-8') as file: for line in file: line = line.strip() if line.startswith('`') and ':' in line: parts = line.split(':') user_agent_device_id = parts[0].strip('`') user_agent_device_name = ':'.join(parts[1:]).strip() matches.append((user_agent_device_id, user_agent_device_name)) log_file.write(f'Matched: {user_agent_device_id}, {user_agent_device_name}\n') # 生成SQL插入语句 with open(output_file, 'w', encoding='utf-8') as file: file.write('USE your_database_name;\n') # 替换成你的数据库名称 file.write('INSERT INTO user_agent_device_model (user_agent_device_id, user_agent_device_name) VALUES\n') values = [] for match in matches: user_agent_device_id, user_agent_device_name = match values.append(f"('{user_agent_device_id}', '{user_agent_device_name}')") file.write(",\n".join(values) + ";\n") print(f'SQL insert statements have been written to {output_file}') print(f'Processing log has been written to {log_file_path}')
The text was updated successfully, but these errors were encountered:
截止2024-05-27生成好的sql文件 insert.txt
Sorry, something went wrong.
No branches or pull requests
非常感谢提供详尽的数据。
我写了一段python代码,可以提取目录中型号以及手机名称对应关系,生成sql语句到数据库中,方便大家使用。
The text was updated successfully, but these errors were encountered: