Skip to content

Commit 049504f

Browse files
docs: improve file open in all doc
1 parent 7076130 commit 049504f

3 files changed

Lines changed: 29 additions & 31 deletions

File tree

README.md

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -59,18 +59,14 @@ from hrflow import Hrflow
5959
client = Hrflow(api_secret="YOUR_API_KEY", api_user="YOU_USER_EMAIL")
6060

6161
# read file from directory (in binary mode)
62-
file = open("path_to_file.pdf", "rb")
63-
64-
# Parse it using this method without reference:
65-
response = client.profile.parsing.add_file(
66-
source_key="INSERT_THE_TARGET_SOURCE_KEY",
67-
profile_file=file,
68-
sync_parsing=1, # This is to invoke real time parsing
69-
tags=[{"name": "application_reference", "value": "TS_X12345"}], # Attach an application tag to the profile to be parsed
70-
)
71-
72-
# Close the file
73-
file.close()
62+
with open("path_to_file.pdf", "rb") as profile_file:
63+
# Parse it using this method without reference:
64+
response = client.profile.parsing.add_file(
65+
source_key="INSERT_THE_TARGET_SOURCE_KEY",
66+
profile_file=file,
67+
sync_parsing=1, # This is to invoke real time parsing
68+
tags=[{"name": "application_reference", "value": "TS_X12345"}], # Attach an application tag to the profile to be parsed
69+
)
7470
```
7571

7672

examples/colab/implement_hrflow_in_5min.ipynb

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -220,19 +220,20 @@
220220
},
221221
"outputs": [],
222222
"source": [
223-
"profile_file = open(ROOT_PATH+'/original.pdf',\"rb\")\n",
223+
"with open(os.path.join(ROOT_PATH, \"original.pdf\"),\"rb\") as profile_file:\n",
224+
" resp = client.profile.parsing.add_file(\n",
225+
" source_key=\"source_key\",\n",
226+
" profile_file=profile_file,\n",
227+
" profile_content_type='application/pdf',\n",
228+
" reference='12334324234',\n",
229+
" tags=[],\n",
230+
" metadatas=[],\n",
231+
" created_at=\"2020-01-01T00:00:00\",\n",
232+
" sync_parsing=1,\n",
233+
" sync_parsing_indexing=1,\n",
234+
" webhook_parsing_sending=0\n",
235+
" )\n",
224236
"\n",
225-
"resp = client.profile.parsing.add_file(source_key=\"source_key\",\n",
226-
" profile_file=profile_file,\n",
227-
" profile_content_type='application/pdf',\n",
228-
" reference='12334324234',\n",
229-
" tags=[],\n",
230-
" metadatas=[],\n",
231-
" created_at=\"2020-01-01T00:00:00\",\n",
232-
" sync_parsing=1,\n",
233-
" sync_parsing_indexing=1,\n",
234-
" webhook_parsing_sending=0)\n",
235-
"profile_file.close()\n",
236237
"profile = resp['data']['profile']\n",
237238
"pprint.pprint(profile)"
238239
]

examples/profile/profile_endpoints_examples.ipynb

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1017,18 +1017,19 @@
10171017
"\n",
10181018
"import os \n",
10191019
"\n",
1020-
"binary_profile = open(\"/home/parsing/Documents/test_resume.pdf\", \"rb\") # <-- Replace with your file path\n",
1021-
"\n",
10221020
"# Add tags to the profile to be parsed \n",
10231021
"tags = [\n",
10241022
" {\"name\": \"origin\", \"value\": \"linkedin\"},\n",
10251023
" {\"name\": \"availability\", \"value\": \"immediate\"},\n",
10261024
"]\n",
1027-
"response = client.profile.parsing.add_file(source_key=source_key,\n",
1028-
" profile_file=binary_profile,\n",
1029-
" tags=tags,\n",
1030-
" sync_parsing=1) # <-- This is optional, to enable sync_parsing reach out to enable it on the source\n",
1031-
"binary_profile.close()\n",
1025+
"with open(\"/home/parsing/Documents/test_resume.pdf\", \"rb\") as binary_profile: # <-- Replace with your file path\n",
1026+
" response = client.profile.parsing.add_file(\n",
1027+
" source_key=source_key,\n",
1028+
" profile_file=binary_profile,\n",
1029+
" tags=tags,\n",
1030+
" sync_parsing=1 # <-- This is optional, to enable sync_parsing reach out to enable it on the source\n",
1031+
" )\n",
1032+
"\n",
10321033
"response"
10331034
]
10341035
},

0 commit comments

Comments
 (0)