Hi All,
I have no background in scripting in any of the languages.I am trying to write one awk script which can actually read a csv file and stable sort each column and return the output in pivoted form.
So, for the sample csv file below:

Akhtar,MNNIT,INDIA
Azhar,LU,PAKISTAN
Bob,MIT,USA
Raj,Purdue,INDIA
Ahmed,Illionis,USA
Akhtar,IITK,INDIA
Ramesh,IITB,INDIA
Bob,stanford,USA

I'll have the output as below:

<columnId,RowId,Value>

so the output will be:

0,0,Akhtar
0,1,Akhtar
0,2,Bob
0,7,Bob
........
........
2,0,INDIA
2,3,INDIA
2,5,INDIA
----------
and so on

I could try upto this:

sort --stable -t"," -k2 Lymphography.csv | awk -F, '{print 0","$1","$2}' > output.csv

but it does not return stable sort results. Also, I do not know how to write this as a program which reads input from file and sorts each column and print as mentioned above

# What you need is to look into the "Built-in Variables" section of "man awk"
sort --stable -t"," -k2 in.csv | awk -F, '{print 0 "," NR-1 "," $1}'
# NR - 1 as you want row num to start from 0 whereas awk does it from 1.
# Add more prints for $2, $3,...
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.