I would like to format some text to the protein data bank file format. Basically what I need to do is start the text in specific columns. Right now I’m doing the formatting using ljust and rjust but I feel like there should be some magic function that I could use give a word and in what column it should start.
Any help would be greatly appreciated. Thanks
If my Statckoverflow searching failed, please point me in that direction.
Here is an example of how one might format a “Coordinate Record Description” using str.format:
The format specifier
CRDis interpreted this way:{r:<6}tellsformatto string-interpolate the value ofstr(r), left justified, with width=6.{a:>9.3f}tellsformatto string-interpolate the float value ofa, right justified, with total width 9 and 3 digits after the decimal point.The complete description of how the format specified works is given here.