Categories
Uncategorized

Formatting Integers – Python

We have a range from 1 to 100 and we want to format the integers so that they look nice. Something like this so first we create the range which should result in something like this The actual formatting code is quite simple, this But to apply it to a list, we can do this […]

Categories
Uncategorized

Formatting Dates – Python

We have a date like this 3rd April 2013 and we want to change it to this 2013-04-03 We can change the date format using the datetime module. In this module we can use strptime( ) to tell Python that the string is a date, and then strftime( ) to change the date to the […]

Categories
Uncategorized

Reformatting dates – Python

This little script will reformat a series of dates in a file, from 22 April 1980 to a more compact 19800422 ([yyyymmdd]) ISO standard, using the re and time libraries. Start with a file containing a series of dates Then this is the python code Now the output file will read