您可以将csv转换为pandas.DataFrame
,然后使用applymap()
转换所有值。
import pandas as pd
test = pd.read_csv("Test.csv")
reps = {
'rechts': 'right','rechts schiebend': 'right pushing'
}
translator = lambda x: reps[x] if x in reps else x
modified_test = test.applymap(translator)
modified_test.to_csv('Test_en.csv',index=None) # save result
,
您可以尝试以下解决方案:
Starting backup at 06-NOV-19
using channel ORA_DISK_1
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of backup command at 11/06/2019 05:14:17
RMAN-06018: duplicate operand specified in backup specification: DFORMAT
' RMAN> }'
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-00558: error encountered while parsing input commands
RMAN-01009: syntax error: found "}": expecting one of: "advise,allocate,alter,backup,@,catalog,change,configure,connect,convert,copy,create,crosscheck,delete,drop,duplicate,exit,flashback,grant,host,import,list,mount,open,print,quit,recover,register,release,repair,replace,report,reset,restore,resync,revoke,run,send,set,show,shutdown,spool,sql,startup,switch,transport,unregister,upgrade,validate,{,"
RMAN-01007: at line 1 column 1 file: standard input
它应该将csv更新为
import re
csv = 'rechts,rechts schiebend,schiebend,schiebend rechts'
reps = {
'rechts' : 'right','rechts schiebend' : 'right pushing'
}
cells = csv.split(',')
for idx,cell in enumerate(cells):
if cell in reps:
cells[idx] = re.sub(re.compile('^' + cell + '$'),reps[cell],cell)
csv = ','.join(cells)
print(csv)
本文链接:https://www.f2er.com/3154258.html