or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

entry-interface.mdindex.mdinstance-management.mdintegration-utilities.mdlisteners-events.mdpersistence-data.mdtable-operations.md

table-operations.mddocs/

0

# Table Operations

1

2

Table-based interface for reading and writing values in NetworkTable hierarchies. Provides convenient methods for all supported data types, table navigation, and bulk operations on related data.

3

4

## Capabilities

5

6

### Entry Access and Navigation

7

8

Navigate tables and access entries within the hierarchy.

9

10

```python { .api }

11

class NetworkTable:

12

def getEntry(key: str) -> NetworkTableEntry:

13

"""

14

Get an entry by key within this table.

15

16

Parameters:

17

- key: str. Entry key within this table (not full path)

18

19

Returns:

20

NetworkTableEntry: Entry object for type-safe operations

21

"""

22

23

def containsKey(key: str) -> bool:

24

"""

25

Check if a key exists in this table.

26

27

Parameters:

28

- key: str. Entry key to check

29

30

Returns:

31

bool: True if key exists, False otherwise

32

"""

33

34

def getKeys(types: int = 0) -> List[str]:

35

"""

36

Get all keys in this table, optionally filtered by type.

37

38

Parameters:

39

- types: int. Bitmask of entry types to include (default: 0 for all)

40

41

Returns:

42

List[str]: List of keys in this table

43

"""

44

45

def getSubTables() -> List[str]:

46

"""

47

Get names of all subtables within this table.

48

49

Returns:

50

List[str]: List of subtable names

51

"""

52

53

def getSubTable(key: str) -> NetworkTable:

54

"""

55

Get a subtable by name.

56

57

Parameters:

58

- key: str. Subtable name

59

60

Returns:

61

NetworkTable: Subtable object

62

"""

63

64

def containsSubTable(key: str) -> bool:

65

"""

66

Check if a subtable exists.

67

68

Parameters:

69

- key: str. Subtable name to check

70

71

Returns:

72

bool: True if subtable exists, False otherwise

73

"""

74

75

def getPath() -> str:

76

"""

77

Get the full path of this table.

78

79

Returns:

80

str: Full table path (e.g., "/SmartDashboard")

81

"""

82

```

83

84

### Numeric Value Operations

85

86

Store and retrieve numeric (double) values.

87

88

```python { .api }

89

def putNumber(key: str, value: float):

90

"""

91

Put a numeric value into the table.

92

93

Parameters:

94

- key: str. Entry key

95

- value: float. Numeric value to store

96

"""

97

98

def getNumber(key: str, defaultValue: float) -> float:

99

"""

100

Get a numeric value from the table.

101

102

Parameters:

103

- key: str. Entry key

104

- defaultValue: float. Value to return if key doesn't exist

105

106

Returns:

107

float: Entry value or default value

108

"""

109

110

def setDefaultNumber(key: str, defaultValue: float):

111

"""

112

Set default value for a numeric entry without overwriting existing values.

113

114

Parameters:

115

- key: str. Entry key

116

- defaultValue: float. Default value to set

117

"""

118

```

119

120

### String Value Operations

121

122

Store and retrieve string values.

123

124

```python { .api }

125

def putString(key: str, value: str):

126

"""

127

Put a string value into the table.

128

129

Parameters:

130

- key: str. Entry key

131

- value: str. String value to store

132

"""

133

134

def getString(key: str, defaultValue: str) -> str:

135

"""

136

Get a string value from the table.

137

138

Parameters:

139

- key: str. Entry key

140

- defaultValue: str. Value to return if key doesn't exist

141

142

Returns:

143

str: Entry value or default value

144

"""

145

146

def setDefaultString(key: str, defaultValue: str):

147

"""

148

Set default value for a string entry without overwriting existing values.

149

150

Parameters:

151

- key: str. Entry key

152

- defaultValue: str. Default value to set

153

"""

154

```

155

156

### Boolean Value Operations

157

158

Store and retrieve boolean values.

159

160

```python { .api }

161

def putBoolean(key: str, value: bool):

162

"""

163

Put a boolean value into the table.

164

165

Parameters:

166

- key: str. Entry key

167

- value: bool. Boolean value to store

168

"""

169

170

def getBoolean(key: str, defaultValue: bool) -> bool:

171

"""

172

Get a boolean value from the table.

173

174

Parameters:

175

- key: str. Entry key

176

- defaultValue: bool. Value to return if key doesn't exist

177

178

Returns:

179

bool: Entry value or default value

180

"""

181

182

def setDefaultBoolean(key: str, defaultValue: bool):

183

"""

184

Set default value for a boolean entry without overwriting existing values.

185

186

Parameters:

187

- key: str. Entry key

188

- defaultValue: bool. Default value to set

189

"""

190

```

191

192

### Array Value Operations

193

194

Store and retrieve array values of various types.

195

196

```python { .api }

197

def putNumberArray(key: str, value: List[float]):

198

"""

199

Put a numeric array into the table.

200

201

Parameters:

202

- key: str. Entry key

203

- value: List[float]. Numeric array to store

204

"""

205

206

def getNumberArray(key: str, defaultValue: List[float]) -> List[float]:

207

"""

208

Get a numeric array from the table.

209

210

Parameters:

211

- key: str. Entry key

212

- defaultValue: List[float]. Value to return if key doesn't exist

213

214

Returns:

215

List[float]: Entry value or default value

216

"""

217

218

def putStringArray(key: str, value: List[str]):

219

"""

220

Put a string array into the table.

221

222

Parameters:

223

- key: str. Entry key

224

- value: List[str]. String array to store

225

"""

226

227

def getStringArray(key: str, defaultValue: List[str]) -> List[str]:

228

"""

229

Get a string array from the table.

230

231

Parameters:

232

- key: str. Entry key

233

- defaultValue: List[str]. Value to return if key doesn't exist

234

235

Returns:

236

List[str]: Entry value or default value

237

"""

238

239

def putBooleanArray(key: str, value: List[bool]):

240

"""

241

Put a boolean array into the table.

242

243

Parameters:

244

- key: str. Entry key

245

- value: List[bool]. Boolean array to store

246

"""

247

248

def getBooleanArray(key: str, defaultValue: List[bool]) -> List[bool]:

249

"""

250

Get a boolean array from the table.

251

252

Parameters:

253

- key: str. Entry key

254

- defaultValue: List[bool]. Value to return if key doesn't exist

255

256

Returns:

257

List[bool]: Entry value or default value

258

"""

259

```

260

261

### Raw Data Operations

262

263

Store and retrieve raw byte data.

264

265

```python { .api }

266

def putRaw(key: str, value: bytes):

267

"""

268

Put raw byte data into the table.

269

270

Parameters:

271

- key: str. Entry key

272

- value: bytes. Raw data to store

273

"""

274

275

def getRaw(key: str, defaultValue: bytes) -> bytes:

276

"""

277

Get raw byte data from the table.

278

279

Parameters:

280

- key: str. Entry key

281

- defaultValue: bytes. Value to return if key doesn't exist

282

283

Returns:

284

bytes: Entry value or default value

285

"""

286

```

287

288

### Generic Value Operations

289

290

Store and retrieve values with automatic type detection.

291

292

```python { .api }

293

def putValue(key: str, value):

294

"""

295

Put a value into the table with automatic type detection.

296

297

Parameters:

298

- key: str. Entry key

299

- value: Any. Value to store (bool, float, str, bytes, or arrays thereof)

300

"""

301

302

def getValue(key: str, defaultValue) -> Any:

303

"""

304

Get a value from the table with automatic type handling.

305

306

Parameters:

307

- key: str. Entry key

308

- defaultValue: Any. Value to return if key doesn't exist

309

310

Returns:

311

Any: Entry value or default value

312

"""

313

314

def setDefaultValue(key: str, defaultValue):

315

"""

316

Set default value for an entry without overwriting existing values.

317

318

Parameters:

319

- key: str. Entry key

320

- defaultValue: Any. Default value to set

321

"""

322

```

323

324

### Entry Management

325

326

Manage entries within the table.

327

328

```python { .api }

329

def delete(key: str):

330

"""

331

Delete an entry from the table.

332

333

Parameters:

334

- key: str. Entry key to delete

335

"""

336

```

337

338

### Persistence Control

339

340

Control which values persist across NetworkTables restarts.

341

342

```python { .api }

343

def setPersistent(key: str):

344

"""

345

Make an entry persistent across restarts.

346

347

Parameters:

348

- key: str. Entry key to make persistent

349

"""

350

351

def clearPersistent(key: str):

352

"""

353

Remove persistence from an entry.

354

355

Parameters:

356

- key: str. Entry key to make non-persistent

357

"""

358

359

def isPersistent(key: str) -> bool:

360

"""

361

Check if an entry is persistent.

362

363

Parameters:

364

- key: str. Entry key to check

365

366

Returns:

367

bool: True if entry is persistent, False otherwise

368

"""

369

370

def setFlags(key: str, flags: int):

371

"""

372

Set flags for an entry.

373

374

Parameters:

375

- key: str. Entry key

376

- flags: int. Bitmask of flags to set

377

"""

378

379

def clearFlags(key: str, flags: int):

380

"""

381

Clear flags for an entry.

382

383

Parameters:

384

- key: str. Entry key

385

- flags: int. Bitmask of flags to clear

386

"""

387

388

def getFlags(key: str) -> int:

389

"""

390

Get flags for an entry.

391

392

Parameters:

393

- key: str. Entry key

394

395

Returns:

396

int: Bitmask of entry flags

397

"""

398

```

399

400

### Listener Management

401

402

Add and remove listeners for table changes.

403

404

```python { .api }

405

def addEntryListener(listener: Callable, immediateNotify: bool = False,

406

key: str = None, localNotify: bool = False):

407

"""

408

Add a listener for entry changes in this table.

409

410

Parameters:

411

- listener: Callable. Function called when entries change

412

- immediateNotify: bool. Call listener immediately with current values

413

- key: str, optional. Specific key to watch (None for all keys in table)

414

- localNotify: bool. Whether to notify on local changes

415

"""

416

417

def removeEntryListener(listener):

418

"""

419

Remove an entry listener.

420

421

Parameters:

422

- listener: Callable. Previously added listener function

423

"""

424

425

def addSubTableListener(listener: Callable, localNotify: bool = False):

426

"""

427

Add a listener for subtable creation/deletion.

428

429

Parameters:

430

- listener: Callable. Function called when subtables change

431

- localNotify: bool. Whether to notify on local changes

432

"""

433

```

434

435

### Advanced Entry Access

436

437

Get auto-updating entry objects for efficient access patterns.

438

439

```python { .api }

440

def getAutoUpdateValue(key: str, defaultValue, writeDefault: bool = True) -> NetworkTableEntry:

441

"""

442

Get an auto-updating entry that caches the latest value.

443

444

Parameters:

445

- key: str. Entry key

446

- defaultValue: Any. Default value if entry doesn't exist

447

- writeDefault: bool. Whether to write default value to table

448

449

Returns:

450

NetworkTableEntry: Entry that automatically updates with latest value

451

"""

452

```

453

454

## Usage Examples

455

456

### Basic Table Operations

457

458

```python

459

from networktables import NetworkTables

460

461

# Get SmartDashboard table

462

sd = NetworkTables.getTable('SmartDashboard')

463

464

# Store different types of data

465

sd.putNumber('speed', 42.5)

466

sd.putString('status', 'running')

467

sd.putBoolean('enabled', True)

468

sd.putNumberArray('pose', [1.2, 3.4, 0.5])

469

470

# Read data with defaults

471

speed = sd.getNumber('speed', 0.0)

472

status = sd.getString('status', 'unknown')

473

enabled = sd.getBoolean('enabled', False)

474

pose = sd.getNumberArray('pose', [0.0, 0.0, 0.0])

475

```

476

477

### Table Navigation

478

479

```python

480

from networktables import NetworkTables

481

482

# Navigate table hierarchy

483

root = NetworkTables.getGlobalTable()

484

vision = root.getSubTable('Vision')

485

camera1 = vision.getSubTable('Camera1')

486

487

# List available data

488

print("Available keys:", vision.getKeys())

489

print("Available subtables:", vision.getSubTables())

490

491

# Check for specific data

492

if vision.containsKey('targetDistance'):

493

distance = vision.getNumber('targetDistance', 0.0)

494

```

495

496

### Persistence and Flags

497

498

```python

499

from networktables import NetworkTables

500

501

sd = NetworkTables.getTable('SmartDashboard')

502

503

# Make configuration values persistent

504

sd.putNumber('maxSpeed', 1.0)

505

sd.setPersistent('maxSpeed')

506

507

# Set defaults without overwriting

508

sd.setDefaultString('autonomousMode', 'defense')

509

sd.setDefaultBoolean('compressorEnabled', True)

510

511

# Check persistence

512

if sd.isPersistent('maxSpeed'):

513

print("Max speed will persist across restarts")

514

```

515

516

## Constants

517

518

```python { .api }

519

# Table path separator

520

PATH_SEPARATOR = "/"

521

```