Skip to content

Instantly share code, notes, and snippets.

@sepastian
Created April 16, 2025 07:04
Show Gist options
  • Save sepastian/e06f934760c2c97116f62cd750d68bbf to your computer and use it in GitHub Desktop.
Save sepastian/e06f934760c2c97116f62cd750d68bbf to your computer and use it in GitHub Desktop.
Quote a list of strings
# Given a comma-separated list of strings,
# quote each string separately in double-quotes
# for exampe, for using the list of strings in Python.
#
# Use sed to replace word boundaries (\b) with a quote character (").
head -1 some_csv_file.csv | sed -e 's|\b|"|g'
# head -1 topic_to_policy_llm_CORRECTED.csv
# topic_id,match,policy_field_flo,policy_field_llm,topic,source,policy_id_llm
# head -1 topic_to_policy_llm_CORRECTED.csv | sed -e 's|\b|"|g'
# "topic_id","match","policy_field_flo","policy_field_llm","topic","source","policy_id_llm"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment