Convert .csv to Excel file and email as attachment

Issue

I’m trying to convert a .csv file to Excel using unix shell script. Tried replacing pipe delimited to comma separated using the below script.

#!/bin/bash
cd /main/subpath/dev/Int/Source/adm/at/csv_xls
for f in *.csv; do 
sed 's/^\||/,/g' "$f" > "${f%.csv}.xls"
done
ls *.csv;
echo "CSV Excel Con" | mailx -s "Testing CSV2Excel" -a "${f%.csv}.xls" [email protected]

I have multiple Excel files. I need to send all the Excel files as email attachments. When I tried using this script it is attaching only one file.

Solution

You can simply use ssconvert

ssconvert file1.csv file1.xlsx

Answered By – lapourgagner

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published