Data tables stripping leading zeros

If you print out your d dictionary before adding the row, you should see that the leading zeroes have already been stripped. A text field in a data table will definitely not strip anything. You can verify that yourself by adding a row without going through the CSV import and making sure that there are leading zeroes in the text field.

The stripping has to be happening during the CSV import. This seems to be a known issue with Pandas, that it treats the field as an integer. This post suggests that the syntax for your dtype argument isn’t correct: Keeping leading zeroes when using read_csv in Pandas

2 Likes