Date: prev next · Thread: first prev next last
2013 Archives by date, by thread · List index



On 2013-04-11 18:17, Alex Thurgood wrote:
Le 11/04/2013 02:47, Joel Madero a écrit :

Hi Joel,

A quick trawl reveals several possibilities :

http://stackoverflow.com/questions/4749658/inserting-filename-into-last-column-of-csv-file


http://stackoverflow.com/questions/9506810/add-column-to-end-of-csv-file-using-awk-in-bash-script

http://www.unix.com/shell-programming-scripting/213419-add-extra-column-csv-file.html


etc


Alex
Hi Alex.
First example implements easily.
Converts all files with extension .csv
Not sure if the OP  wants to append 2012_01_02.csv or just 2012_01_02

Assuming the latter, the following worked for me in a bash file. Copy the files to a new directory for conversion as the files will be altered, new files are not created. These strip the .csv.

#!/bin/bash
for file in *.csv; do
    file1=${file%.*}
    sed -i "s/$/,$file1/" "$file"
done

For tab separated files
for file in *.csv; do
    file1=${file%.*}
    sed -i "s/$/\t$file1/" "$file"
done

Steve

--
For unsubscribe instructions e-mail to: users+help@global.libreoffice.org
Problems? http://www.libreoffice.org/get-help/mailing-lists/how-to-unsubscribe/
Posting guidelines + more: http://wiki.documentfoundation.org/Netiquette
List archive: http://listarchives.libreoffice.org/global/users/
All messages sent to this list will be publicly archived and cannot be deleted

Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.