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
  • 216,930
  • 22
  • 195
  • 267
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.
  • 3,136
  • 2
  • 7
  • 24
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
  • 223,850
  • 36
  • 205
  • 328