read_api.rst 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. read_api
  2. ==========
  3. Read the content from file or directory to create ``Dataset``, Currently we provided serval functions that cover some scenarios.
  4. if you have new scenarios that is common to most of the users, you can post it on the offical github issues with detail descriptions.
  5. Also it is easy to implement your own read-related funtions.
  6. Important Functions
  7. -------------------
  8. read_jsonl
  9. ^^^^^^^^^^^^^^^^
  10. Read the contet from jsonl which may located on local machine or remote s3. if you want to know more about jsonl, please goto :doc:`../../additional_notes/glossary`
  11. .. code:: python
  12. from magic_pdf.data.io.read_api import *
  13. # read jsonl from local machine
  14. datasets = read_jsonl("tt.jsonl", None)
  15. # read jsonl from remote s3
  16. datasets = read_jsonl("s3://bucket_1/tt.jsonl", s3_reader)
  17. read_local_pdfs
  18. ^^^^^^^^^^^^^^^^
  19. Read pdf from path or directory.
  20. .. code:: python
  21. from magic_pdf.data.io.read_api import *
  22. # read pdf path
  23. datasets = read_local_pdfs("tt.pdf")
  24. # read pdfs under directory
  25. datasets = read_local_pdfs("pdfs/")
  26. read_local_images
  27. ^^^^^^^^^^^^^^^^^^^
  28. Read images from path or directory
  29. .. code:: python
  30. from magic_pdf.data.io.read_api import *
  31. # read from image path
  32. datasets = read_local_images("tt.png")
  33. # read files from directory that endswith suffix in suffixes array
  34. datasets = read_local_images("images/", suffixes=["png", "jpg"])
  35. Check :doc:`../../api/read_api` for more details