1820475 Members
3337 Online
109624 Solutions
New Discussion юеВ

converting ascii to csv

 
SOLVED
Go to solution
lawrenzo_1
Super Advisor

converting ascii to csv

Hello,

I need to convert an ascii file to csv file. I have used the below command with no luck:

uuencode file.ascii file.csv |mail etc etc

however the file is too large to be mailed.

can this be done using dd if not then what command would be best?

Thanks
hello
4 REPLIES 4
Hein van den Heuvel
Honored Contributor
Solution

Re: converting ascii to csv

cvs stands for 'comma seperated values'.
It is still ascii. Is just means turning for example
------ ascii input ---
aap noot mies
teun piet
------ csv output ----
aap,noot,mies
teun,piet
-----------------------

It gets tricky when quoting and embedded spaces are involved.

A simple conversion with perl can be:

perl -pe '$_=join(",",split)."\n"' file

with awk and assuming 4 columns:

awk 'BEGIN {OFS=","}{print $1,$2,$3,$4}' file


What problem are you exactly trying to solve? What is, where is the input? How much is there roughly: KB? MB? GB? What should the output look like, where should it go? Mind you, we can probably NOT solve your mail problems


Regards,
Hein.
lawrenzo_1
Super Advisor

Re: converting ascii to csv

the full command;

uuencode file.dat file.csv |mailx -m -N -s ^DQUOTE^BT Rejected File ^DQUOTE^ mail@xexche01.mail.com

this is a job that is automated and to run against a file on a unix box then send a mail to user's in our business.

as explained it failed due to size as stated in the logs so we need to ftp the file instead but as csv.

Thanks

Lawz
hello
Bill Hassell
Honored Contributor

Re: converting ascii to csv

Did the file fail at the local machine or get rejected by the remote mail system? sendmail.cf has controls (depending on the version of sendmail you have) to limit large files. The other problem is that /var and/or /tmp may be too small. Note that file more than a few megs are really not appropriate for email. There are so many systems that limit maximum email size that it is hard to get large files to transmit successfully.

ftp is a good choice, but like email, EVERYTHING in the message may be seen by snoopers. You should consider sftp (Secure Shell FTP) to secure the data.


Bill Hassell, sysadmin
lawrenzo_1
Super Advisor

Re: converting ascii to csv

Thanks for your replies!

I found that when the extention .dat was changed to csv and then opened by excel, the fields were populated as expected
hello