Title: Design pattern - data exporter
Tags: design-patterns;export
Question: I have a problem to solve where I export data from one system, into some intermediary database tables for another system to pick up.

There is a specific format for each object type and the associated fields i.e.:


Orders

Order id (int 10 - padded left with zeros if under - error if over)
Customer Name (varchar 150 - trimmed if over)
Customer address line 1 (varchar 250 - trimmed if over)



Aside from some brute force logic, listing each field, its data type and maximum length, then looping over each field in the object to enforce those rules ready to be exported, is there a more elegant solution or pattern for this type of problem.

Im assuming this is pretty much a standard problem throughout many years of business programs and must have been solved countless times.

Comment: the source data structure is different to the target

Comment: Isn't this just straight forward SQL?



{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 0, 'CommentCount': 2, 'ContentLicense': 'CC BY-SA 3.0', 'CreationDate': '2015:00:04/08/15', 'FavoriteCount': None, 'PostTypeId': 1, 'Tags': '<design-patterns><export>', 'Title': 'Design pattern - data exporter', 'ViewCount': 130, 'id': 29518300, 'user_AboutMe': '', 'user_AccountId': 1223829.0, 'user_DisplayName': 'Marty Wallace', 'user_Reputation': 32138.0, 'user_Views': 881.0, 'user_id': 1189880.0}}