sciencehistory / scihist_digicoll

Science History Institute Digital Collections
Other
11 stars 0 forks source link

Convert inches to cm in Extent field of museum objects #2656

Open Gabz73 opened 2 weeks ago

Gabz73 commented 2 weeks ago

Museum objects use inches instead of cm in Past Perfect. We want to convert the extent statements to metric. Can this be done on the back end? Conversion s/b 2.54 cm per inch, with one decimal point retained.

eddierubeiz commented 2 weeks ago

This is perfectly feasible, but it's not a 10-minute job either.

See e.g.: https://digital.sciencehistory.org/works/fb4948977 for an example: all the dimensions are contained in one string. So we want a recipe that can take a few hundred strings of the form: 10.25 in. H x 8.25 in. (each of which can contain up to three separate dimensions in inches) and return a string with each value converted appropriately, and of course with the new units.

jrochkind commented 2 weeks ago

Yep. i'd use a regex to look for something like /(\d+\.?\d*) in\./. and just replace each one with ${converted_to_cm} cm

The code doesn't need to know whether there are two dimensions or three or that the dimensions might be lableled with W or anything, just replaces every XX.XX in. with XX.X cm. Only in the specific field(s) specified. (I think just extent)

Does need some testing to make sure no data corruption, it is a bit risky true! Still a human doing it manually would probably make some errors too!