Re: Howto merge gnumeric files



El dg 17 de 02 del 2008 a les 16:32 +0100, en/na Hans Martin va
escriure:

. Same problem with gnumeric 1.6.3. Other ideas?

Use the console, gnumeric files are xml/text gzipped, so you can use the
standard text tools to work with them.
Save the following under a file named join_gnumeric

####join_gnumeric#####
#!/bin/sh

if file $1|grep gzip>/dev/null 2>&1
then CAT1=zcat
else CAT1=cat
fi

if file $2|grep gzip>/dev/null 2>&1
then CAT2=zcat
else CAT2=cat
fi

## Output up to closing sheet index on first file.
$CAT1 $1 |sed -n '\%</gnm:SheetNameIndex>%,$! p'

## Adding index and sheets of second file.
$CAT2 $2 |sed -n '1,\%<gnm:SheetNameIndex>%! {\%</gnm:Sheets>%,$! p}'

## Adding sheets of first file up to end
$CAT1 $1 |sed -n '\%<gnm:Sheet %,$ {p}'

####/join_gnumeric####


Ensure there are not duplicate sheet names between the files, save and
backup them.

Then run the following:
sh join_gnumeric file1.gnumeric file2.gnumeric>temp.gnumeric 
sh join_gnumeric temp.gnumeric file3.gnumeric>joined.gnumeric
rm temp.gnumeric
gnumeric joined.gnumeric


Just tested with 3 small files and with gnumeric 1.6.3, Hope this
works with more complicated files or different gnumeric versions.

Hope this helps

Pere




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]