Skip to content

Instantly share code, notes, and snippets.

@blairmacintyre
Created February 20, 2020 16:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save blairmacintyre/479178dd5ffb53619fa2351a6975fefe to your computer and use it in GitHub Desktop.
Save blairmacintyre/479178dd5ffb53619fa2351a6975fefe to your computer and use it in GitHub Desktop.
convert a "email, name" csv to the json file needed by hubs-cloud account upload
#!/bin/sh
awk '
BEGIN {
print "{ \"data\": ["
FS = ",[ \t]+"
first = 1
}
{
if (first) { first = 0 } else { print ","}
email = gensub("\"", "\\\\\"", "G", $1)
name = gensub("\"", "\\\\\"", "G", $2)
print "{ \"email\": \"" email "\", \"name\": \"" name "\"}"}
END {print "]}"}
'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment