- Notifications
You must be signed in to change notification settings - Fork0
Rparadox: A Modern Interface for Reading Paradox Databases in R
License
celebithil/Rparadox
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
Rparadox provides a simple and efficient way to read data fromParadox database files (.db) directly into R as moderntibble dataframes. It uses the underlyingpxlib C library to handle the low-levelfile format details and provides a clean, user-friendly R interface.
This package is designed to “just work” for the most common use case:extracting the full dataset from a Paradox table, including itsassociated BLOB/memo file (.mb).
- Direct Reading: Reads Paradox
.dbfiles without needing databasedrivers or external software. - Tibble Output: Returns data in the
tibbleformat, which is fullycompatible with the Tidyverse ecosystem. - Automatic BLOB Handling: Automatically detects, attaches, andreads data from associated memo/BLOB (
.mb) files. - Character Encoding Control: Automatically handles characterencoding conversion to UTF-8 and allows the user to manually overridethe source encoding for files with incorrect headers.
- Type Conversion: Correctly maps Paradox data types to theircorresponding R types, including
Date,Time(hms),Timestamp(POSIXct),Logical,Integer,Numeric, and binaryblobobjects.
# stable version from CRANinstall.packages("Rparadox")
You can install the development version of Rparadox from GitHub usingthedevtools package.
# install.packages("devtools")devtools::install_github("celebithil/Rparadox")
The easiest way to read a Paradox file is with the high-levelread_paradox() function. It handles opening the file, reading thedata, and closing the connection in a single step.
# 1. Load the packagelibrary(Rparadox)# 2. Get the path to an example databasedb_path<- system.file("extdata","biolife.db",package="Rparadox")# 3. Read the data directly into a tibble# This automatically finds 'biolife.mb' and handles data types.biolife_data<- read_paradox(db_path)# 4. View the dataprint(biolife_data)#> # A tibble: 28 × 8#> `Species No` Category Common_Name `Species Name` `Length (cm)` Length_In#> <dbl> <chr> <chr> <chr> <dbl> <dbl>#> 1 90020 Triggerfish Clown Trig… Ballistoides … 50 19.7#> 2 90030 Snapper Red Emperor Lutjanus sebae 60 23.6#> 3 90050 Wrasse Giant Maor… Cheilinus und… 229 90.2#> 4 90070 Angelfish Blue Angel… Pomacanthus n… 30 11.8#> 5 90080 Cod Lunartail … Variola louti 80 31.5#> 6 90090 Scorpionfish Firefish Pterois volit… 38 15.0#> 7 90100 Butterflyfish Ornate But… Chaetodon Orn… 19 7.48#> 8 90110 Shark Swell Shark Cephaloscylli… 102 40.2#> 9 90120 Ray Bat Ray Myliobatis ca… 56 22.0#> 10 90130 Eel California… Gymnothorax m… 150 59.1#> # ℹ 18 more rows#> # ℹ 2 more variables: Notes <chr>, Graphic <blob>
If you have a legacy file where the encoding is specified incorrectly inthe header, you can manually override it using theencoding parameterwithread_paradox().
library(Rparadox)# This tells the package to interpret the source data as CP866data<- read_paradox("path/to/your/file.db",encoding="cp866")
This ensures that all text fields are correctly converted to UTF-8 inthe finaltibble.
For more control, you can use the lower-level functions. This is usefulif you want to inspect metadata before reading the full dataset.
library(Rparadox)db_path<- system.file("extdata","biolife.db",package="Rparadox")# 1. Open the file and get a handlepxdoc<- pxlib_open_file(db_path)if (!is.null(pxdoc)) {# 2. Get metadata without reading all the datametadata<- pxlib_metadata(pxdoc) cat("Number of records:",metadata$num_records,"\n")# 3. Read the actual datadata_table<- pxlib_get_data(pxdoc)# 4. Always close the file when you're done pxlib_close_file(pxdoc)}#> Number of records: 28
- pxlib C library:https://github.com/steinm/pxlib
- CRAN page:https://cran.r-project.org/package=Rparadox
- Bug reports:https://github.com/celebithil/Rparadox/issues
About
Rparadox: A Modern Interface for Reading Paradox Databases in R
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
Uh oh!
There was an error while loading.Please reload this page.
