The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Help on email data file as excel from unix!! sparan_peddu Shell Programming and Scripting 1 10-19-2008 03:08 AM
manipulate data with specific format tonet Shell Programming and Scripting 5 04-25-2008 12:24 PM
how to read the data from an excel sheet and use those data as variable in the unix c Anne Grace UNIX for Advanced & Expert Users 1 03-03-2008 07:21 AM
sed or other tool to manipulate data, including email addresses manouche Shell Programming and Scripting 3 02-19-2008 05:53 PM
reading data from excel using shell script tiger99 Shell Programming and Scripting 11 01-06-2008 01:35 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 11-26-2008
rahulrathod rahulrathod is offline
Registered User
  
 

Join Date: Sep 2004
Location: Mumbai-India
Posts: 158
Lightbulb Excel data manipulate

All,

I have the following format of data in a spreadsheet

Code:
A	1
            2
            3
            4
B	1
            2
            3
            4
where 'A' is value of 'A1', '1 2 3 4' is value of cell B1, 'B' is value of cell A2, and '1 2 3 4' is value of cell B2.

There are thousands of rows with such a data format in the spreadsheet.

Is there any way which you can think where I can get this data in the followin format.

Code:
A          1
A          2
A          3
A          4
B          1
B          2
B          3
B          4
I was thinking if I could convert the spreadsheet to a csv and do some manipulations using sheel script.

The above is just an example format. the data in the cells in spreadsheet may be different.

Regards,
Rahul.
  #2 (permalink)  
Old 11-26-2008
Franklin52 Franklin52 is offline Forum Staff  
Moderator
  
 

Join Date: Feb 2007
Posts: 4,315
It seems that your cells have different properties (amounts and text) in the same column. Select the whole column and change the property for the whole column.

Regards
  #3 (permalink)  
Old 11-26-2008
mk1216 mk1216 is offline
Registered User
  
 

Join Date: Sep 2008
Location: Bristol , United Kingdom
Posts: 38
I think we first need to see data in csv , then can think of using shell.
  #4 (permalink)  
Old 11-26-2008
rahulrathod rahulrathod is offline
Registered User
  
 

Join Date: Sep 2004
Location: Mumbai-India
Posts: 158
Yes. Data in csv, will come like this

A,"1234"
B,"1234"

for the spreadsheet.

But what if data is like

A abcd
cdab
B abcd
fedh

I wont be able to distinguish the cell values.

The problem is cells in column B have multiple values separated by new line char in the excel. and i want this to be mapped individually to cell value in column A.
  #5 (permalink)  
Old 11-26-2008
CarlosNC CarlosNC is offline
Registered User
  
 

Join Date: Oct 2008
Posts: 6
Assuming the number of columns is consistent throughout, and in this case is 1 or 2, an awk script might look like:
Code:
awk -F, '
NF == 2 {x=$1; print; next}
NF == 1 {print x","$1}
' infile > outfile
Cheers
  #6 (permalink)  
Old 11-26-2008
CarlosNC CarlosNC is offline
Registered User
  
 

Join Date: Oct 2008
Posts: 6
If there are spaces instead of commas, just remove the -F, from the statement, and replace "," with " " in the third line.
Code:
awk '
NF == 2 {x=$1; print; next}
NF == 1 {print x" "$1}
' infile > outfile
  #7 (permalink)  
Old 11-26-2008
rahulrathod rahulrathod is offline
Registered User
  
 

Join Date: Sep 2004
Location: Mumbai-India
Posts: 158
Ok. Lets make it simple. I have got the data into a csv file as follows.

Code:
A,"YAHOO3456-K9YAHOO9876YAHOO67/2YAHOO65432-1"
B,"YAHOO01YAHOO07865YAHOO67-AD987/1YAHOO67/23"
And what I want as the output is
Code:
A,YAHOO3456-K9
A,YAHOO9876
A,YAHOO67/2
A,YAHOO65432-1
B,YAHOO01
B,YAHOO07865
B,YAHOO67-AD987/1
B,YAHOO67/23
The format that would be common is YAHOOxxxxx in the 2nd column.

Let me know if you can think of an easy conversion.

Thanks,
Rahul.
Closed Thread

Bookmarks

Tags
shell script, shell scripting, unix scripting, unix scripting basics

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 08:21 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0