I want to the following results in my csv file :
<code>-----------------------------------------------------------------------
sdp_name | source_count | target_count | match_status | business_date |
-----------------------------------------------------------------------
ABC | 2167 | 2167 | matching | 20240510 |
EFG | 123 | 0 | not matching | 20240510 |
-----------------------------------------------------------------------
</code>
<code>-----------------------------------------------------------------------
sdp_name | source_count | target_count | match_status | business_date |
-----------------------------------------------------------------------
ABC | 2167 | 2167 | matching | 20240510 |
EFG | 123 | 0 | not matching | 20240510 |
-----------------------------------------------------------------------
</code>
-----------------------------------------------------------------------
sdp_name | source_count | target_count | match_status | business_date |
-----------------------------------------------------------------------
ABC | 2167 | 2167 | matching | 20240510 |
EFG | 123 | 0 | not matching | 20240510 |
-----------------------------------------------------------------------
I’m using the following code :
<code>headers = ['sdp_name', 'source_count', 'target_count', 'match_status', 'business_date']
rows = []
not_matching_found = False
for key in count_target_impala.keys():
sdp_name = key
source_count = count_source_impala.get(key)
target_count = count_target_impala.get(key)
match_status = 'matching' if source_count == target_count else 'not matching'
if match_status == 'not matching':
not_matching_found = True
rows.append(['sdp_name', 'source_count', 'target_count', 'match_status', 'business_date'])
save_path = '/home/neha/'
with open(save_path, mode = 'w', newline='', encoding='utf-8') as file:
writer = csv.writer(file)
writer.writerow(headers)
writer.writerow(rows)
</code>
<code>headers = ['sdp_name', 'source_count', 'target_count', 'match_status', 'business_date']
rows = []
not_matching_found = False
for key in count_target_impala.keys():
sdp_name = key
source_count = count_source_impala.get(key)
target_count = count_target_impala.get(key)
match_status = 'matching' if source_count == target_count else 'not matching'
if match_status == 'not matching':
not_matching_found = True
rows.append(['sdp_name', 'source_count', 'target_count', 'match_status', 'business_date'])
save_path = '/home/neha/'
with open(save_path, mode = 'w', newline='', encoding='utf-8') as file:
writer = csv.writer(file)
writer.writerow(headers)
writer.writerow(rows)
</code>
headers = ['sdp_name', 'source_count', 'target_count', 'match_status', 'business_date']
rows = []
not_matching_found = False
for key in count_target_impala.keys():
sdp_name = key
source_count = count_source_impala.get(key)
target_count = count_target_impala.get(key)
match_status = 'matching' if source_count == target_count else 'not matching'
if match_status == 'not matching':
not_matching_found = True
rows.append(['sdp_name', 'source_count', 'target_count', 'match_status', 'business_date'])
save_path = '/home/neha/'
with open(save_path, mode = 'w', newline='', encoding='utf-8') as file:
writer = csv.writer(file)
writer.writerow(headers)
writer.writerow(rows)
instead of getting the desired results as mentioned above i’m getting this :
<code>-----------------------------------------------------------------------
sdp_name | source_count | target_count | match_status | business_date |
-----------------------------------------------------------------------
[ABC,2167,2167,matching,20240510] | [EDF,123,0,not matching,20240510]
</code>
<code>-----------------------------------------------------------------------
sdp_name | source_count | target_count | match_status | business_date |
-----------------------------------------------------------------------
[ABC,2167,2167,matching,20240510] | [EDF,123,0,not matching,20240510]
</code>
-----------------------------------------------------------------------
sdp_name | source_count | target_count | match_status | business_date |
-----------------------------------------------------------------------
[ABC,2167,2167,matching,20240510] | [EDF,123,0,not matching,20240510]
I want to the following results in my csv file :
<code>-----------------------------------------------------------------------
sdp_name | source_count | target_count | match_status | business_date |
-----------------------------------------------------------------------
ABC | 2167 | 2167 | matching | 20240510 |
EFG | 123 | 0 | not matching | 20240510 |
-----------------------------------------------------------------------
</code>
<code>-----------------------------------------------------------------------
sdp_name | source_count | target_count | match_status | business_date |
-----------------------------------------------------------------------
ABC | 2167 | 2167 | matching | 20240510 |
EFG | 123 | 0 | not matching | 20240510 |
-----------------------------------------------------------------------
</code>
-----------------------------------------------------------------------
sdp_name | source_count | target_count | match_status | business_date |
-----------------------------------------------------------------------
ABC | 2167 | 2167 | matching | 20240510 |
EFG | 123 | 0 | not matching | 20240510 |
-----------------------------------------------------------------------
instead of getting the desired results as mentioned above i’m getting this :
<code>-----------------------------------------------------------------------
sdp_name | source_count | target_count | match_status | business_date |
-----------------------------------------------------------------------
[ABC,2167,2167,matching,20240510] | [EDF,123,0,not matching,20240510]
</code>
<code>-----------------------------------------------------------------------
sdp_name | source_count | target_count | match_status | business_date |
-----------------------------------------------------------------------
[ABC,2167,2167,matching,20240510] | [EDF,123,0,not matching,20240510]
</code>
-----------------------------------------------------------------------
sdp_name | source_count | target_count | match_status | business_date |
-----------------------------------------------------------------------
[ABC,2167,2167,matching,20240510] | [EDF,123,0,not matching,20240510]
New contributor
Aakriti Mittal is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.