-- coding: utf-8 --
“”"
Created on Fri Oct 18 20:58:07 2024
@author: M.D
“”"
import pandas as pd
df = pd.read_csv(“transversalSkillsCollection_翻译.csv”)
data = df[“altLabels 替代标签”]
原始数据,每条数据由英文和中文组成
data = “”"
take the initiative 积极主动
give impetus 推动
be a driving force 成为驱动力
demonstrate sense of initiative 展示主动性
initiate action 发起行动
show sense of initiative 展现主动性
show active initiative 展现积极的主动性
implement environmental choices in your own eating habit 将环保选择融入自己的饮食习惯
adopt a sustainable eating habit 采用可持续的饮食习惯
promoting organic and biological food consumption 促进有机和生物食品的消费
“”"
分割文本为每一行
df get()
lines = data.strip().split(‘\n’)
提取英文和中文,按倒数第一个空格分割
english = []
chinese = []
for line in lines:
eng, chn = line.rsplit(’ ', 1) # 使用rsplit从右侧第一个空格进行分割
english.append(eng)
chinese.append(chn)
创建DataFrame
df = pd.DataFrame({‘English’: english, ‘Chinese’: chinese})
保存为CSV文件
df.to_csv(‘soft_skills_separated_all.csv’, index=False, encoding=‘utf-8-sig’)
print(“CSV file saved successfully.”)