My problem at hand is to get the data from API's and input that data into csv. I'm able to get the data, however outputting the data into csv is where I'm getting the error. Can someone please help.
Here is the sample code:
import csv,sys
def read_campaign_info(campaigns):
myfile = csv.writer(open("output.csv", "w"))
for insight in reach_insights:
account_id = str(insight[AdsInsights.Field.account_id])
objective = str(insight[AdsInsights.Field.objective])
metrics =[account_id,objective]
wr = csv.writer(myfile,quoting=csv.QUOTE_ALL)
wr.writerows(metrics)
Type of variable metrics
is <class 'list'>
Error that I'm getting is
wr = csv.writer(myfile,quoting=csv.QUOTE_ALL)
TypeError: argument 1 must have a "write" method