I have a table that has a column of integer values representing atomic numbers. I know of the command:
string replace={---}{\textemdash}
However this is table-wide. I want to match the values in a specific column, and replace it with a lookup value. Either through multiple replace statements (I will only be dealing with a few integers: 1,6,7,8,16 I think are the only possible integers I'll need). Or preferably through some sort of lookup table.
Is there a method for this type of substitution. I can rewrite the python script that generates these tables, but they are spread across many locations, and it would be considerable effort to pull together a whole new set of them for this single purpose. I would like to replace the values found in the atomicnum column. I've included a sample csv file below:
atomnum,atomicnum,x,y,z
1,6,0.000001,0.700530,-1.910890 2,6,0.000001,1.438902,-0.717628
3,6,0.000000,0.696419,0.453609 4,6,0.000000,-0.696419,0.453609
5,6,-0.000001,-1.438902,-0.717628 6,6,-0.000001,-0.700530,-1.910890
7,1,0.000001,1.224386,-2.862243 8,1,0.000002,2.524808,-0.733291
9,6,0.000001,-0.786842,1.970076 10,1,0.890609,-1.241092,2.412264
11,6,-0.000001,0.786842,1.970076 12,1,0.890605,1.241095,2.412266
13,1,-0.890609,1.241092,2.412264 14,1,-0.890605,-1.241095,2.412266
15,1,-0.000002,-2.524808,-0.733291 16,1,-0.000001,-1.224386,-2.862243
The table that pgfplotstable
would "see" would be substituted according a pseudocode array like the following:
temp[] = {1=>"H", 6=>"C", 7=>"N", 8=>"O", 16=>"S"}
The table used and output is then:
atomnum,atomicnum,x,y,z
1,C,0.000001,0.700530,-1.910890
2,C,0.000001,1.438902,-0.717628
3,C,0.000000,0.696419,0.453609
4,C,0.000000,-0.696419,0.453609
5,C,-0.000001,-1.438902,-0.717628
6,C,-0.000001,-0.700530,-1.910890
7,H,0.000001,1.224386,-2.862243
8,H,0.000002,2.524808,-0.733291
9,C,0.000001,-0.786842,1.970076
10,H,0.890609,-1.241092,2.412264
11,C,-0.000001,0.786842,1.970076
12,H,0.890605,1.241095,2.412266
13,H,-0.890609,1.241092,2.412264
14,H,-0.890605,-1.241095,2.412266
15,H,-0.000002,-2.524808,-0.733291
16,H,-0.000001,-1.224386,-2.862243