forked from MTMurphy77/MMatomdat
-
Notifications
You must be signed in to change notification settings - Fork 0
/
MMatomdat_csv2tex.csh
executable file
·28 lines (23 loc) · 983 Bytes
/
MMatomdat_csv2tex.csh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/bin/tcsh
set INPREFIX = 'MMatomdat'
set INSUFFIX = '.csv'
set OUTPREFIX = 'MM'
set OUTVERS = `date "+%Y-%m-%d"`
set OUTSUFFIX = '.tex'
set TABHEAD = 'MMatomdat_table_head.tex'
set TABTAIL = 'MMatomdat_table_tail.tex'
foreach ELEMENT ( Na Mg Al Si Ca Ti Cr Mn Fe Ni Zn )
set CSVFILE = `echo $INPREFIX"_"$ELEMENT$INSUFFIX`
set OUTFILE = `echo $OUTPREFIX"_"$ELEMENT"-"$OUTVERS$OUTSUFFIX` ; rm -f $OUTFILE; touch $OUTFILE
set CAPFILE = `echo $INPREFIX"_"$ELEMENT"_caption"$OUTSUFFIX`
set TABLABEL = `echo $ELEMENT`
@ SLINE = 1; @ ELINE = `grep -n "CAPTION" $TABHEAD | awk '{printf "%d",substr($1,1,length($1)-1)}'`; @ ELINE = $ELINE - 1;
@ NLINE = `wc $TABHEAD | awk '{print $1}'`
printline $TABHEAD $SLINE $ELINE >> $OUTFILE
cat $CAPFILE >> $OUTFILE
@ SLINE = ($NLINE - $ELINE) - 1
tail -$SLINE $TABHEAD | sed 's/LABEL/'$TABLABEL'/' >> $OUTFILE
awk -f MMatomdat_csv2tex.awk $CSVFILE >> $OUTFILE
cat $TABTAIL >> $OUTFILE
end
exit