Loading ...
Sorry, an error occurred while loading the content.

49766comma-separated fields - conversion, 1 line to N

Expand Messages
  • Jacob Lerner
    Apr 30, 2004
    • 0 Attachment
      Hello,

      A friend of mine asked me how to convert file with these fields:
      country,code1,code2,...,codeN
      into
      country,code1
      country,code2
      ...
      country,codeN

      N is variable in each line. FIelds are comma-separated.
      I gave him awk solution
      awk -F, '{country=$1; for(i=2; i<=NF; i++) print $1 " " $(i); }'
      but he doesn't have awk or perl (Win2k)

      How to do it in vim ?

      Yakov
    • Show all 8 messages in this topic