Excel data manipulate


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Excel data manipulate
# 8  
Old 11-26-2008
nawk -f rahul.awk myFile.csv

rahul.awk:
Code:
BEGIN {
  # variable qq contains the value of double-quote
  qq=sprintf("%c", 034)

  # FieldSeparator (FS) can either be a ",", a double-quote or a string "YAHOO"
  # all the fields in a record/line will be broken down by the values of the FS
  FS="([,])|(" qq ")|(YAHOO)"
}
{
   # iterate through the fields of a current record/line starting from the FOURTH field in
   # a record/line and going to the NEXT to LAST field print: 
   # the value of the FIRST field ($1), followed by "," , followed by string "YAHOO" and 
   # followed the current iterator field ($i)
   for(i=4; i<=NF-1; i++)
     printf("%s,YAHOO%s\n", $1, $i)
}


Last edited by vgersh99; 11-26-2008 at 12:56 PM.. Reason: added comments
# 9  
Old 11-26-2008
Hi Vgresh99,

Thanks for the instant post, can you breakup the command and let us know please .
# 10  
Old 11-26-2008
Quote:
Originally Posted by mk1216
Hi Vgresh99,

Thanks for the instant post, can you breakup the command and let us know please .
see updated code comments - HTH
# 11  
Old 11-26-2008
Thanks for the script. I did run it, but I got the following output in myFile.csv

Code:
A,"YAHOO3456-K9
YAHOO9876
YAHOO67/2
YAHOO65432-1"
B,"YAHOO01
YAHOO07865
YAHOO67-AD987/1
YAHOO67/23"

I'll check and modify the script accordingly. Thanks.
# 12  
Old 11-26-2008
given a sample file myFile.csv:
Code:
A,"YAHOO3456-K9YAHOO9876YAHOO67/2YAHOO65432-1"
B,"YAHOO01YAHOO07865YAHOO67-AD987/1YAHOO67/23"

and a script posted previously, I get the following output:
Code:
A,YAHOO3456-K9
A,YAHOO9876
A,YAHOO67/2
A,YAHOO65432-1
B,YAHOO01
B,YAHOO07865
B,YAHOO67-AD987/1
B,YAHOO67/23

Make sure you properly copy/paste the code - it does not need to be changed.
# 13  
Old 11-27-2008
Apologies.

The format is different when I view the csv on Windows and Unix.

On windows it appears as I mentioned previously
Code:
A,"YAHOO3456-K9YAHOO9876YAHOO67/2YAHOO65432-1"
B,"YAHOO01YAHOO07865YAHOO67-AD987/1YAHOO67/23"


and on Unix it appears as follows.

Code:
A,"YAHOO3456-K9
YAHOO9876
YAHOO67/2
YAHOO65432-1"
B,"YAHOO01
YAHOO07865
YAHOO67-AD987/1
YAHOO67/23"

And hence I did not get the required o/p. I will modify your script accordingly.

Thanks.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Help - manipulate data by columns and repeated

Hello good afternoon to everyone. I'm new to the forum and would like to request your help in handling data. I hope my English is clear. I have a file (Dato01.txt) to contine the following structure. # Col1 - Col2 - Col3 - Col4 Patricia started Jun 22 05:22:58 Carolina started Jun... (5 Replies)
Discussion started by: kelevra
5 Replies

2. Shell Programming and Scripting

Script to generate Excel file or to SQL output data to Excel format/tabular format

Hi , i am generating some data by firing sql query with connecting to the database by my solaris box. The below one should be the header line of my excel ,here its coming in separate row. TO_CHAR(C. CURR_EMP_NO ---------- --------------- LST_NM... (6 Replies)
Discussion started by: dani1234
6 Replies

3. Shell Programming and Scripting

Summing up the data from different excel sheet into one excel sheet

Hi Folks, Can you please advise for any script in unix such that for example , i have 3 different excel sheet at the location /ppt/gfr/exc so the name s of the excel sheet are 1excel.xslx 2excel.xslx 3excel.xslx now in these 3 different excel sheet there is lot of data for example each... (3 Replies)
Discussion started by: punpun66
3 Replies

4. Shell Programming and Scripting

Extract & Manipulate continous data stream-- tcpdump

Hello; I have this rather tricky problem to solve --(to me, anyways) .. I am processing the following one liner with tcpdump.. tcpdump -i T3501 -A ether host 00:1e:49:29:fc:c9 or ether host 00:1b:2b:86:ec:1b or ether host 00:21:1c:98:a4:08 and net 149.83.6.0/24 | grep --line-buffered -B... (5 Replies)
Discussion started by: delphys
5 Replies

5. Shell Programming and Scripting

Need help to manipulate data using script

Hi i want to manipulate my data to convert row to column name 600 Slno vlan 1 600 2 609 3 700 name 700 Slno vlan 1 600 2 609 3 700 (8 Replies)
Discussion started by: nith_anandan
8 Replies

6. Shell Programming and Scripting

Manipulate data in detail problem facing

Input Participant number: HAC Position type Location Distance_start Distance_end Range Mark 1 1 + Front 808 1083 276 2 1 + Front 1373 1636 264 3 1 - Back 1837 2047 211 Participant number: BCD Position type... (6 Replies)
Discussion started by: patrick87
6 Replies

7. Shell Programming and Scripting

how to manipulate with lines while playing with data

hello everyone, well I have a file which contains data, I want to add the data on hourly basis, like my file contains data for 24 hours, (so a total of 1440 ) lines. Now i want to add the data on hourly basis to get average values. like if I use (head) command it is ok for first go, but... (5 Replies)
Discussion started by: jojo123
5 Replies

8. Shell Programming and Scripting

manipulate data with specific format

Hi everybody: I have a problem with how I have to manipulate the data which have specific format like this: 249. 0.30727021E+05 0.30601627E+05 0.37470780E-01 -0.44745335E+02 0.82674536E+03 248. 0.30428182E+05 0.30302787E+05 0.40564921E-01 -0.45210293E+02 ... (5 Replies)
Discussion started by: tonet
5 Replies

9. UNIX for Advanced & Expert Users

how to read the data from an excel sheet and use those data as variable in the unix c

I have 3 columns in an excel sheet. c1 c2 c3 EIP_ACCOUNT SMALL_TS_01 select A.* from acc; All the above 3 col shoud be passed a variable in the unix code. 1.How to read an excel file 2.How to pass these data as variable to the unic script (1 Reply)
Discussion started by: Anne Grace
1 Replies

10. Shell Programming and Scripting

sed or other tool to manipulate data, including email addresses

I have a list of names and email addresses, like this. The <tab> markers are actually tabs. joe.blow <tab> joe.blow@wherever.com tom.t.hall <tab> tom.t.hall@wherever.com john.r.smith <tab> john.r.smith@wherever.com sally.jones <tab> sally.jones@state.or.us I want to parse the data so that... (3 Replies)
Discussion started by: manouche
3 Replies
Login or Register to Ask a Question