Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

api test.py 1.7 KB

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
  1. # -*- coding: utf-8 -*-
  2. """
  3. Created on Wed Mar 11 16:18:40 2020
  4. @author: hsuwei
  5. """
  6. import os
  7. import pandas as pd
  8. import re
  9. import numpy as np
  10. from pathlib import Path
  11. import sys
  12. from pyzotero import zotero
  13. ibrary_id = '6442814'
  14. ibrary_type = 'user'
  15. api_key = 'RmNVIoIEegFWxPiiVW6fKr17'
  16. zot = zotero.Zotero(ibrary_id, ibrary_type, api_key)
  17. # we now have a Zotero object, zot, and access to all its methods
  18. first_ten = zot.items(limit=10)
  19. # a list containing dicts of the ten most recently modified library items
  20. # Read my csv
  21. os.chdir('C:\\Users\\user\\Desktop\\2020\\up')
  22. df0 = pd.read_csv('airi.csv')
  23. keep = ['Item Type',
  24. 'Publication Year',
  25. 'Author',
  26. 'Title',
  27. 'Publication Title',
  28. 'DOI',
  29. 'Url',
  30. 'Pages',
  31. 'Num Pages',
  32. 'Issue',
  33. 'Volume',
  34. 'Publisher',
  35. 'Place',
  36. 'Language',
  37. 'Rights',
  38. 'Type',
  39. 'Extra',
  40. 'Conference Name'
  41. ]
  42. df = df0.loc[:, keep]
  43. ex = df.iloc[0, :]
  44. template = zot.item_template(ex[0])
  45. template['creators'][0]['lastName'] = (ex['Author'])
  46. # template['creators'][0]['lastName'] = 'Cantsin'
  47. template['title'] = ex['Title']
  48. template['publicationTitle'] = ex['Publication Title']
  49. template['volume'] = ex['Volume']
  50. template['issue'] = ex['Issue']
  51. # template['pages'] = ex['Pages']
  52. # template['date'] = ex['']
  53. # template['language'] = ex['Language']
  54. # template['DOI'] = ex['DOI']
  55. # template['ISSN'] = ex['']
  56. # template['url'] = ex['Url']
  57. # template['accessDate'] = ex['']
  58. # template['rights'] = ex['Rights']
  59. # template['extra'] = ex['Extra']
  60. # template['tags'] = ex['']
  61. # template['collections'] = ex['']
  62. # TODO: 不能用nan
  63. resp = zot.create_items([template])
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...