I have a rather monolithic database I am re-building at the moment, and I want to join 3 tables with semi-matching content, I have several sets of these but they all come in groups of three. Here is the situation:
–note all tables are in ascii format, space deliminated —
T1_01= Table 1 =
1 + 'stuff1' + additional content 1 (where additional content only sometimes available)
2 ""
3 ""
....400
T1_02= Table 2 =
1 + "different stuff" + additional content 2
2 ""
3 ""
... 400
T1_03 = Table 3 =
5 cols yet other stuff + 001 + additional content 3
5 cols yet other stuff + 003 ""
5 cols yet other stuff + 007 ""
...
5 cols yet other stuff + 399 some rows are skipped, varies which ones
5 cols yet other stuff + 400
what I want, for each ‘group’ I have 3 tables, since these are grouped in a handy fashion, ie T1_01, T1_02, T1_03 would be table 1,2,3 for group 1, and again for T2_01,T2_02,T2_03. I need to do this about 60 times in total and the table output I am hoping for is:
T1_0123=
1 + 'stuff1' + additional content 1 1 + "different stuff" + additional content 2 5 cols yet other stuff + 001 + additional content 3
2 + 'stuff1' + additional content 1 2 + "different stuff" + additional content 2 "something to fill in the empty spaces, like a set of -99.9 values"
3 + 'stuff1' + additional content 1 3 + "different stuff" + additional content 2 5 cols yet other stuff + 003 + additional content 3
...
400 ""
now I did an initial run and
join -1 1 -2 1 T1_01 T1_02 > T1_012 works great, but only does the first two
and
join -1 1 -2 6 T1_01 T1_03 … does not work since 001 is not 1
and I was hoping to run all 3 tables in a go then do something like
sed something awk $(cat list_of_T01) $(cat list_of_T02) $(cat list_of_T03) to run as a batch job. I have been learning python so this may be possible there as well, but I surely AWK is easier? Any suggestions are welcome.
Try this one:
or this one if your delimiter isn’t space: