chunk_serializer
This file provides a single function serialize_in_chunks() which can serialize a
Graph into a number of NT files with a maximum number of triples or maximum file size.
There is an option to preserve any prefixes declared for the original graph in the first file, which will be a Turtle file.
Functions:
-
serialize_in_chunks–Serializes a given Graph into a series of n-triples with a given length.
serialize_in_chunks
serialize_in_chunks(g: Graph, max_triples: int = 10000, max_file_size_kb: Optional[int] = None, file_name_stem: str = 'chunk', output_dir: Optional[Path] = None, write_prefixes: bool = False) -> None
Serializes a given Graph into a series of n-triples with a given length.
Parameters:
-
(gGraph) –The graph to serialize.
-
(max_file_size_kbOptional[int], default:None) –Maximum size per NT file in kB (1,000 bytes) Equivalent to ~6,000 triples, depending on Literal sizes.
-
(max_triplesint, default:10000) –Maximum size per NT file in triples Equivalent to lines in file. If both this parameter and max_file_size_kb are set, max_file_size_kb will be used.
-
(file_name_stemstr, default:'chunk') –Prefix of each file name. e.g. “chunk” = chunk_000001.nt, chunk_000002.nt…
-
(output_dirOptional[Path], default:None) –The directory you want the files to be written to.
-
(write_prefixesbool, default:False) –The first file created is a Turtle file containing original graph prefixes.
See ../test/test_tools/test_chunk_serializer.py for examples of this in use.
Source code in rdflib/tools/chunk_serializer.py
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 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 | |