1

I have a csv as below I needed that formatted .

current format

a,b,c,d,e
1,2,3,4,5

Desired Output

a,
b,
c,
d,
e

1,
2,
3,
4,
5
choroba
  • 231,213
  • 25
  • 204
  • 289
siddharth
  • 11
  • 1

3 Answers3

1

Try a script like this:

#!/bin/bash

file=$1

cat ${file} | while read line
do 
  echo $line | sed 's/,/,\n/g'
  echo
done

Or if you don't need a blank line after each translated lines:

cat filename.csv | sed 's/,/,\n/g'
Rachid K.
  • 4,490
  • 3
  • 11
  • 30
0

You can try with:

sed "1G;s/,/,\n/g" file.csv

Append a new line then replace "," with ",newline"

0

You tagged and , so a bash answer:

while IFS= read -r line; do
    printf "%s\n\n" "${line//,/$',\n'}"
done < file.csv
glenn jackman
  • 238,783
  • 38
  • 220
  • 352