Guest User

Untitled

a guest
Jan 11th, 2019
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. ENDPOINT_URL = 'https://tash.example.com/api_v1/journal'
  2. Header = {'Api-key': 'abc1234'}
  3.  
  4. with open('coa.csv', 'r') as csv_ledger:
  5. r = csv.DictReader(csv_ledger)
  6. data = [dict(d) for d in r]
  7.  
  8. groups = []
  9.  
  10. for k, g in groupby(data, lambda r:
  11. (r['Code'],r['Description'],r['Account_Type_ID'])):
  12. groups.append({
  13. "date": "2018-10-10",
  14. "name": "gfgfh",
  15. "code": k[0],
  16. "desc": k[1],
  17. "account_type_id": k[2],
  18. })
  19.  
  20. post_api = requests.post(ENDPOINT_URL, json=groups,headers=Header)
Add Comment
Please, Sign In to add comment