Feb-04-2021, 12:12 PM
Hello experts,
I have an array as shown below with 6 common elements repeated for 20-100 entries and want to extract the elements with 'Power' in the first column and put it in a text file with 'Filtered' word appended at the beginning of each line. appreicate your help.
[inline]input array:
a = [{'sec': 'coalmine', 'country': 'usa', 'state': 'newyork', 'zip': '17304', 'amt': '15480', 'tg': '910-456-8415'},
{'sec': 'coalPower', 'country': 'uk', 'state': 'birmingham', 'zip': '51730', 'amt': '26663', 'tg': '321-854-7536'},
.
.
.
.
{'sec': 'hydelPower', 'country': 'usa', 'state': 'sanfrancisco', 'zip': '92416', 'amt': '748521', 'tg': '451-278-9632'}]
[/inline]
[inline]
output to text file
comments sec(Power) state tg
filtered coalpower birmingham 321-854-7536
filtered hydelPower usa 451-278-9632
[/inline]
I have an array as shown below with 6 common elements repeated for 20-100 entries and want to extract the elements with 'Power' in the first column and put it in a text file with 'Filtered' word appended at the beginning of each line. appreicate your help.
[inline]input array:
a = [{'sec': 'coalmine', 'country': 'usa', 'state': 'newyork', 'zip': '17304', 'amt': '15480', 'tg': '910-456-8415'},
{'sec': 'coalPower', 'country': 'uk', 'state': 'birmingham', 'zip': '51730', 'amt': '26663', 'tg': '321-854-7536'},
.
.
.
.
{'sec': 'hydelPower', 'country': 'usa', 'state': 'sanfrancisco', 'zip': '92416', 'amt': '748521', 'tg': '451-278-9632'}]
[/inline]
[inline]
output to text file
comments sec(Power) state tg
filtered coalpower birmingham 321-854-7536
filtered hydelPower usa 451-278-9632
[/inline]