I am receiving a CSV response from API. I want to append the received CSV response to already present CSV file in my machine. Problem i am facing is it is also appending the header from second CSV file. I want to remove that header. I have also attached screenshot of how my csv looks after appending.
screenshot
screenshot of the response recieved
I am trying this code
response = requests.get(Link)
actual_file = glob.glob(path_to_data+'\\Data\\*')
new_target_file = path_to_data+'\\Data'+'\\'+State+'_'+date+'_'+St_Id+'.csv'
# Write to .CSV
if not os.path.exists(new_target_file):
for x in response.text.split('\n')[1:]:
f = open(actual_file[0], "a")
f.write(x)
f.close()
os.rename(actual_file[0],new_target_file)
else:
logging.warning("File already exist")