Skip to content

Instantly share code, notes, and snippets.

@ecylmz
Created March 1, 2011 20:23
Show Gist options
  • Save ecylmz/849823 to your computer and use it in GitHub Desktop.
Save ecylmz/849823 to your computer and use it in GitHub Desktop.
#!/usr/bin/awk -f
# input format : student number, full name, e-mail
# output format : full name, user name, student number
# example :
# input : 09060286,"emre can yılmaz","[email protected]"
# output : "emre can yılmaz","canyilmaz",09060286
# usage :
#
# $ chmod +x csv-render
# ./csv-render foo.csv
BEGIN {
FS = ","
}
{
number = $1
if (split($2, a, / /) > 2) {
user = "\"" a[2] "" a[3] # csv'den gelen veride, ad soyad kısmınının " " arasına yazıldığı varsayılmıştır.
first = a[1] " " a[2]
last = a[3]
} else {
user = a[1] "" a[2]
first = a[1]
last= a[2]
}
gsub(/ı/, "i", user)
gsub(/ğ/, "g", user)
gsub(/ü/, "u", user)
gsub(/ş/, "s", user)
gsub(/ç/, "c", user)
gsub(/ö/, "o", user)
printf("%s %s,%s,%s\n", first, last, user, number)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment