perl -lne 'print join ",",map {s/[",]//g;$_}(split /,(?!(?:[^",]+",))/,$_)[0,8]' sample.txt