I have requirement where I am reading a string from json file and assign values to it to make it as a configurable file name.
String I am reading from json:
data_file_format = "sourcesystem_batchid_extractname_loadtype"
I have variable which holds the values in my code like
sourcesystem ="xyz"
batchid = "101"
extractname = "abc"
loadtype = "Delta"
so my data_file_format should yeild value like
data_file_format = "xyz_101_abc_Delta"
There are multiple methods to do that.:
fstring
data_file_format = f'{sourcesystem}_{batchid}_{extractname}_{loadtype}'
or using .format
data_file_format = '{}_{}_{}_{}'.format(sourcetype,batchid,extractname,loadtype)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With