How may I apply double quotes around every value of csv file using TextMate?

后端 未结 3 1440
南方客
南方客 2021-02-09 04:38

I have a csv file with the following format:

example csv:

bear,brown,mean,large
ant,black,strong,tiny
cat,yellow,moody,small
相关标签:
3条回答
  • 2021-02-09 05:21

    You could start with:

    find: ,
    replace: "," 
    

    then add a " at the start and at the end?

    0 讨论(0)
  • 2021-02-09 05:37

    Here are the important portions of the regex. Hopefully I got it right when I converted to textmate format:

    Search - ([^,]*)(,|$)

    Replace - "$1"$2

    Search explanation: Find every character that is not a comma, up until we reach a comma, or the end of the line. Capture the match for string to be quoted in one variable, and capture the comma/end-of-line match in another variable.

    Replace explanation: The original string, quoted, and the comma or end-of-line that follows it.

    0 讨论(0)
  • 2021-02-09 05:38

    This worked great for me. Did the find/replace for rows first

    Then did the simple find / replace for , => ","

    Had to add the first quote, and adding the "Markup" made it easy.

    Thanks and good luck.

    0 讨论(0)
提交回复
热议问题