gpt4 book ai didi

mysql - 每 3 个字符串后用空格替换逗号

转载 作者:行者123 更新时间:2023-11-28 23:35:55 26 4
gpt4 key购买 nike

我有一个如下所示的 csv 文件:

"user1","track1","player1","user1","track2","player2","user1","track3","player3",........

我需要做的是用空格替换逗号(不是所有的逗号),只有 playerIds 之后的那些逗号(指定一行以便稍后将它们导入 Mysql)。所以,我需要这样的结果:

"user1","track1","player1" "user1","track2","player2" "user1","track3","player3" ........

我发现我们可以用 sed 替换带空格的逗号:

sed 's/,/ /g' output.csv >output2.csv

但是,它将所有逗号替换为空格。我不知道如何仅在每 3 个字符串之后执行此操作。任何想法?

谢谢,

最佳答案

您可以像这样使用 sed:

sed -E 's/(([^,]*,){2}[^,]*),/\1 /g' file

"user1","track1","player1" "user1","track2","player2" "user1","track3","player3"

关于mysql - 每 3 个字符串后用空格替换逗号,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35751238/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com