Reading hashed files with jfiles
jfiles is a command that reads hashed files without jBASE or TAFC. It is an implementation of the formats described in this section, written in Python, and is published at pypi.org/project/jfiles. It takes the file type from the first 8 bytes of the file, so the same command works for J3, J4, JP and JR files and for dictionaries.
With uv installed nothing else has to be set up: uvx downloads jfiles and runs it.
COMMAND SYNTAX
uvx jfiles show FILE [KEY ...]
uvx jfiles keys FILE
uvx jfiles get FILE KEY
uvx jfiles dump FILE
uvx jfiles stat FILE
SYNTAX ELEMENTS
| Command | Output |
|---|---|
| show | records as trees of attributes, values and subvalues; all records, or the ones with the given keys |
| keys | the record keys, one on a line, in the order of SELECT |
| get | one record body as it is stored, with its marks |
| dump | every record on a line: the key in hexadecimal, the body length, the body in hexadecimal |
| stat | the file type and the parameters in its header |
NOTES
jfiles only reads. It takes no locks, so do not read a file while jBASE is writing to it: copy the file first.
The exit status is 0 on success, 1 when a record or a file is not found or the file is not a hashed file, and 2 for a wrong command line.
Keys and bodies are printed as UTF-8 when they are valid UTF-8 and as Latin-1 otherwise. Bytes that cannot be printed are shown as \xNN.
EXAMPLE
A J4 file with two records. REC1 has three attributes. REC2 has two values in attribute 2, and two values of three subvalues each in attribute 3:
uvx jfiles stat F.SAMPLE
type=J4 frame=4096 secondary=8192 groups=101 hash=5 flags=0x0 free=0
uvx jfiles keys F.SAMPLE
REC1
REC2
show numbers the parts of a record as jBC does: the line 3.2.1 is REC2<3,2,1>.
uvx jfiles show F.SAMPLE
REC1 (31 bytes)
1: Field one
2: Field two
3: Field three
REC2 (40 bytes)
1: Smith
2:
2.1: London
2.2: Paris
3:
3.1:
3.1.1: 2024
3.1.2: 01
3.1.3: 15
3.2:
3.2.1: 2025
3.2.2: 06
3.2.3: 30
One record by its key:
uvx jfiles show F.SAMPLE REC1
REC1 (31 bytes)
1: Field one
2: Field two
3: Field three
dump prints a record on a line: the key in hexadecimal, the body length and the body in hexadecimal, where the marks can be seen. Here it is REC1, with fe between its attributes:
uvx jfiles dump F.SAMPLE | head -1
52454331 31 4669656c64206f6e65fe4669656c642074776ffe4669656c64207468726565
A record body can be saved to a file as it is stored:
uvx jfiles get F.SAMPLE REC1 > REC1.bin
The same reader can be used from a Python program. Keys and bodies are bytes:
import jfiles
file = jfiles.open('F.SAMPLE')
for key, body in file.records():
print(key, body.split(b'\xfe'))
print(file.read(b'REC1'))