Get Data From CSV File and put into a txt file

Hi Guys,

File A

I have File A as CSV Format....

No	R	SS	MK	Par	value
S	AL	A1	PKL123	Lo12	1
S	AL	A2	PKl123	Lo34	22
S	AL	A3	PkLK234	Lo67	-34
S	AL	A4	PkLK235	Lo09	120
S	AL	A5	PkLK236	Lo76	19
S	AL	A6	PkLK237	Lo44	-17
S	AL	A7	PkLK238	Lo90	2
S	AL	A8	PkLK239	Lo34	-9

I want file B like below......

S+
C+
S PKL123 Lo12 1
S PKl123 Lo34 22
S PkLK234 Lo67 -34
S PkLK235 Lo09 120
S PkLK236 Lo76 19
S PkLK237 Lo44 -17
S PkLK238 Lo90 2
S PkLK239 Lo34 -9
C-
S-

Thanks in Advance....

One way (ksh or bash):

#/usr/bin/env ksh
(
    printf "S+\nC+\n"
    sed '1d; s/\t/ /g' file-A
    printf "C-\nS-\n"
) >file-B

You didn't use code tags, so I'm not 100% sure, but it appears that there were tabs in the input data that you wanted reduced to a single space in the output. If not the sed can be just sed 1d file-A

1 Like

(Added Code Tags to Post #1).
The input file is clearly not CSV (Comma Separated Value) because there are no commas. As @agama notes, please state whether the field separator is tab(s) or space characters or a mixture of both characters.

Looks like there's a little bit more to it than that. Fields 2 and 3 need to be cut. I suppose you can pipe cut into sed or just do it in sed itself.

Regards,
Alister

1 Like

Oops, I so missed that; must be getting old! Thanks