-
Notifications
You must be signed in to change notification settings - Fork 731
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added sample to load word files in ZincSearch
- Loading branch information
1 parent
01ee7ea
commit 23d3da6
Showing
6 changed files
with
34 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Load word files | ||
|
||
You can load word files data in ZincSearch using the script. | ||
|
||
Edit the name of the folder in the load-word-files.py file . All the word files wil be parsed and pushed to the ZincServer. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import textract | ||
import httpx | ||
from os import walk | ||
|
||
folder = "sample-files" | ||
|
||
def main(): | ||
zinc_server = "https://playground.dev.zincsearch.com/api/books/document" | ||
zinc_uid = "admin" | ||
zinc_pwd = "Complexpass#123" | ||
|
||
f = [] | ||
for (dirpath, dirnames, filenames) in walk(folder): | ||
f.extend(filenames) | ||
break | ||
|
||
for file in f: | ||
print(file) | ||
text = textract.process(folder + "/" + file) | ||
text = text.decode("utf-8") | ||
data = { | ||
"file": file, | ||
"text": text | ||
} | ||
|
||
httpx.put(zinc_server, json=data, auth=(zinc_uid, zinc_pwd)) | ||
|
||
if __name__ == "__main__": | ||
main() |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.