comma values to Excel


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting comma values to Excel
# 1  
Old 09-25-2012
comma values to Excel

Hello All,

Got an issue on sending an email with comma seperated values.

Say my file is abc.txt which is

Code:
cat abc.txt
123,456,the american express,America,Day

I will send in a Spread sheet which come in 5 columns. since it has got a space in it, the Spread sheet comes with 7 columns..

I used it as
Code:
cat abc.txt |sed 's/   *,/,/' | sed 's/,/ /g'

Can you please help here..
# 2  
Old 09-25-2012
try using .csv for comma separated files..
# 3  
Old 09-25-2012
This is an error with your spreadsheet software, not the CSV. Excel for instance lets you import with whatever you want as the delimiter...
# 4  
Old 09-26-2012
@Pamu, yes I use that .csv only..

I use that as
Code:
cat abc.txt |sed 's/   *,/,/' | sed 's/,/ /g' > xyz.csv
uuencode xyz.csv xyz.csv | mailx -s "Test" abc@def.com

Still the cells are incorrectly aligned.

@Corona688:
Excel separates the value in the cells by space as default , isn't it?
also this .csv is getting sent to another team who doesn't care on to delimit the values by comma separated. They use on however it comes..

Hence I want my Script to delimit the values into adjacent cells as below
ID1 ID2 Name Country Zt
123 456 the american express America Day

At now, the second row goes in 7 cells due to a space between the values in the Name.
# 5  
Old 09-26-2012
Quote:
Originally Posted by sathyaonnuix
@Pamu, yes I use that .csv only..

I use that as
Code:
cat abc.txt |sed 's/   *,/,/' | sed 's/,/ /g' > xyz.csv
uuencode xyz.csv xyz.csv | mailx -s "Test" abc@def.com

.csv is a comma separated file. And you are removing all the commas.....

try removing above highlighted sed..
This User Gave Thanks to pamu For This Post:
# 6  
Old 09-26-2012
Yeah Pamu, it works out... Learnt what .csv does now.
# 7  
Old 09-26-2012
Quote:
Originally Posted by sathyaonnuix
Hence I want my Script to delimit the values into adjacent cells as below
ID1 ID2 Name Country Zt
123 456 the american express America Day

At now, the second row goes in 7 cells due to a space between the values in the Name.
CSV usually puts double quotes around string values to eliminate those errors with blanks etc. Try double quoting but leave numeric out.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Assign comma separated values to a variable

Hi All, I wrote a database command that queries our application and outputs a whole bunch of values to a text file. I need to assign the output to two values. Here is a sample of the output: valueOne, checkOne valueTwo, checkTwo valueThree, checkThree I would like... (9 Replies)
Discussion started by: jeffs42885
9 Replies

2. Shell Programming and Scripting

Comma separated values to individual lines

My OS : RHEL 6.7 I have a text file with comma separated values like below $ cat testString.txt 'JOHN' , 'KEITH' , 'NEWMAN' , 'URSULA' , 'ARIANNA' , 'CHENG', . . . . I want these values to appear like below 'JOHN' , 'KEITH' , 'NEWMAN' , 'URSULA' , 'ARIANNA' , 'CHENG', .... (4 Replies)
Discussion started by: kraljic
4 Replies

3. Shell Programming and Scripting

Needs help in parsing comma separated values

hello experts, i am retrieving values in variables jobKey and jobName within my shell script. these values are returned to me within braces and i am using following command to remove those braces: jobKeys=`echo $jobKeys | sed 's:^.\(.*\).$:\1:'` jobNames=`echo $jobNames | sed... (1 Reply)
Discussion started by: avikaljain
1 Replies

4. Shell Programming and Scripting

To agregate Comma separated values

Hi pls help me to get the code: i have a file in which content is : 2.01304E+11 2.01304E+11 ori 2 01:00 2.01304E+11 2.01304E+11 ori 2 01:02 2.01304E+11 2.01304E+11 ori 3 01:02 2.01304E+11 2.01304E+11 ori 3 ... (7 Replies)
Discussion started by: Aditya.Gurgaon
7 Replies

5. Shell Programming and Scripting

Input Validation of comma separated values

Hello all, I am working on a script and have the first part solved of numerical input validation. Below the code validates that the input is a numerical value between 100 and 1000. If not, it errors out. Now I need to be able to read values separated by a comma. For example, instead of my... (5 Replies)
Discussion started by: LinuxRacr
5 Replies

6. Shell Programming and Scripting

Extracting the values separated by comma

Hi, I have a variable which has a list of string separated by comma. for ex , Variable=/usr/bin,/usr/smrshbin,/tmp How can i get the values between the commas separately using shell scripts.Please help me. Thanks, Padmini. (6 Replies)
Discussion started by: padmisri
6 Replies

7. Shell Programming and Scripting

How to get values from an excel in a shell script

Hi All, Am trying to write a shell script which will get values from an excel and do some calculations. Can any one pls help me out in the commands used to get the values from ms-excel. Thanks!!!:) (2 Replies)
Discussion started by: msri.1900
2 Replies

8. UNIX Desktop Questions & Answers

Unix Comma Separated to Excel Column

I would like to copy 2 parts of a csv file from Unix to an XL sheet. However to save time I do not want to format the column ever time I cut and paste into XL(Text2Column). I've used awk -F, '{Print $1, $2....}'. Is there a script or code that can automatically format the csv for XL columns? ... (3 Replies)
Discussion started by: ravzter
3 Replies

9. Shell Programming and Scripting

Comma Seperated List of Values

Hi, I have a comma seperated list of values: export list="red,blue,white,yellow" Given a value in a variable "look", i want to check whether the value is available in the above list. But the result should be based on exact string match and not part of the string. I am using following... (9 Replies)
Discussion started by: brap45
9 Replies

10. Shell Programming and Scripting

Splitting comma separated values into an array

I'm attempting to create a KSH array out of a string like this: ",,,value1,value2,," I have created the array but I only get two elements, one for value1 and one for value2. I have ended up with something like this but I don't like it: set -A JUNK xx=0 for i in $(print ",,,value1,value2,,"... (3 Replies)
Discussion started by: tmarikle
3 Replies
Login or Register to Ask a Question