csv file to excel issue


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting csv file to excel issue
# 1  
Old 12-20-2010
csv file to excel issue

Hi,

I am trying to attach and email a csv file in the form of an excel sheet.
And I have been successful in doing this.

But after some days I realised that some fields in the csv file are also having commas because of which this field is getting splitted in columns in the excel sheet.

Is there a way by which I can change the field separator from comma to something else, say a pipe or something?

I use the following command to send the email:

mailx -r from_email@abc.com -s "Subject" to_email@abc.com < <filename.txt>

Could some one assist me on this one please?

Regards,
Girish.
# 2  
Old 12-20-2010
Code:
 
sed 's/,/|/g' csvFile

e.g.
Code:
 
echo "fdfdfdf,dffdf,fdfdf" | sed 's/,/|/g'

gives
Code:
 
fdfdfdf|dffdf|fdfdf

# 3  
Old 12-20-2010
I think he means that he has something like:

"field1", "field 2, with a comma","field 3"

and he wants to change it to

"field1"|"field 2, with a comma"|"field 3"
# 4  
Old 12-20-2010
Quote:
Originally Posted by girish1428
Is there a way by which I can change the field separator from comma to something else, say a pipe or something?
How's awk or sed or whatever supposed to tell the data apart from the delimiters? It will have the same problem as excel. You need to create it with "|" instead of "," in the first place, not translate later. Or fix the code that's injecting the thousands separators or whatever they are.
# 5  
Old 12-20-2010
I'd do it by replacing ", with "|

Last edited by KevinGB; 12-20-2010 at 01:49 PM..
# 6  
Old 12-20-2010
That might work, if and only if the input data is actually formatted like that... Is it?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

How to sort a column in excel/csv file?

I have to sort the 4th column of an excel/csv file. I tried the following command sort -u --field-separator=, --numeric-sort -k 2 -n dinesh.csv > test.csv But, it's not working. Moreover, I have to do the same for more than 30 excel/csv file. So please help me to do the same. (6 Replies)
Discussion started by: dineshkumarsrk
6 Replies

2. Shell Programming and Scripting

Data formatting in CSV file to EXCEL

Hello friends I want to convert an csv file on unix (which is generated by a ETL application) to a formatted excel sheet like .I have roughly like 28 columns 1)All numbers need to be stored as numbers with leading zeros-like format as text for this column to preserve leading zeroes e.g... (6 Replies)
Discussion started by: etldev
6 Replies

3. UNIX for Dummies Questions & Answers

How to extract UNIX output to excel CSV file?

Hi guys - I have a file and output like this below: File: myfile.dat File has content like this: ABCD, 34, 456, 2324 I would like excel to have this: Name (ABCD) Quantity (34), Type (456), Status (2324) (Name, Quantity, Type and Status are columns) I would like to export... (4 Replies)
Discussion started by: DallasT
4 Replies

4. Shell Programming and Scripting

Create an .csv/excel file using shellscript

In my file, i have 4 Product names(For ex:Microsoft excel, Oracle,.Net,IBM websphere,..etc.,) I want this 4 Products in 4 individual .csv/excel file after running the script with those products related information. (12 Replies)
Discussion started by: Navya
12 Replies

5. Shell Programming and Scripting

Shell script - Excel/CSV file - More than one tab

Hi All, Following is my requirement. I have searched the site and found some threads which has same queries, but non of them have any answer. I thought of posting it once more. We are generating different reports through shell script after we finish our data load. Currently there are 7 such... (5 Replies)
Discussion started by: ace_friends22
5 Replies

6. Shell Programming and Scripting

mail a csv file as an excel sheet!

Hi, The result of a script is a csv file in the following format: cat $file_name DATA_USAGE_FACT,YES_NO_FLG,TARGET_TABLE,YES_NO_FLG,1,0,15,0 DATA_USAGE_FACT,DATE_OF_CREATION,TARGET_TABLE,DATE_OF_CREATION,29,9,19,0 DATA_USAGE_FACT,UPDATION_DATE,TARGET_TABLE,UPDATION_DATE,29,9,19,0... (3 Replies)
Discussion started by: dips_ag
3 Replies

7. UNIX for Dummies Questions & Answers

Excel File to CSV

Hi All, I have to convert the excel file which will be placed in the Unix box to a CSV file using a shell script. Please Advise. Thanks & Regards, Kumar66 (1 Reply)
Discussion started by: kumar66
1 Replies

8. Shell Programming and Scripting

How to sort columns in excel(csv) file

i want sort columns with headers based on another file headers file1 eg: i'm having an empty file with only coumn names like lastname firstname title expirydate stlcno status etc... another file with same column names and some other as well but in different order... file2 eg:firstname... (2 Replies)
Discussion started by: Man83Nagesh
2 Replies

9. UNIX for Advanced & Expert Users

Problem in converting password protected excel file to csv file in unix

I need to convert a password protected excel file which will be in UNIX server to a comma separated file. For this I need to open the excel file in UNIX box but the UNIX box doesn't prompt for password instead it is opened in an encrypted manner. I could manually ftp the excel file to local... (2 Replies)
Discussion started by: Devivish
2 Replies

10. Shell Programming and Scripting

text file to excel or csv

Hi, I have a text file like ---------------------- aaa|bbb|ccc|ddd|eee fff|gggg|hhhhhh|kkkk -------------------- I have a script which will transfer(thourgh FTP) this text file to windows system. But I want to covert it into excel or CSF then upload into windows system.. thanks (9 Replies)
Discussion started by: srikanthus2002
9 Replies
Login or Register to Ask a Question