Skip to content

Commit

Permalink
Merge pull request #17 from TidierOrg/add-gen_reader
Browse files Browse the repository at this point in the history
Add gen reader
add reading rdata supprt
  • Loading branch information
drizk1 authored Aug 24, 2024
2 parents 7a7f24b + 6994a70 commit bed8090
Show file tree
Hide file tree
Showing 10 changed files with 289 additions and 102 deletions.
4 changes: 3 additions & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "TidierFiles"
uuid = "8ae5e7a9-bdd3-4c93-9cc3-9df4d5d947db"
authors = ["Daniel Rizk <[email protected]> and contributors"]
version = "0.1.3"
version = "0.1.4"

[deps]
Arrow = "69666777-d1a9-59fb-9406-91d4454c9d45"
Expand All @@ -11,6 +11,7 @@ Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
HTTP = "cd3eb016-35fb-5094-929b-558a96fad6f3"
Parquet2 = "98572fba-bba0-415d-956f-fa77e587d26d"
RData = "df47a6cb-8c03-5eed-afd8-b6050d6c41da"
ReadStatTables = "52522f7a-9570-4e34-8ac6-c005c74d4b84"
Reexport = "189a3867-3050-52da-a836-e630ba90ab69"
XLSX = "fdbf4ff8-1666-58a4-91e7-1b58723a45e0"
Expand All @@ -26,6 +27,7 @@ Parquet2 = "0.2"
ReadStatTables = "0.3"
Reexport = "0.2, 1"
XLSX = "0.10"
RData = "1.0"
julia = "1.9"

[extras]
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ Currently supported file types:
- `read_dta` and `write_dta` (.dta)
- `read_arrow` and `write_arrow`
- `read_parquet` and `write_parquet`
- `read_rdata` (.rdata and .rds)

Agnostic read and write functions that detect the type and dispatch the appropriate function.
- `read_file` and `write_file`

# Examples

Expand Down
15 changes: 15 additions & 0 deletions docs/examples/UserGuide/r_files.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Reading .rds and .rdata files is made possible via RData.jl. There is currently no write support, nor is there url support.

# To read the file, simply pass the path to `read_rdata` or `read_file`. There is a small difference between .rds and .rdata files.
# .rdata files will contain a dict of the table name and the data frame. There can be multiple entries in one .rdata file. To access the data frame, you must pass the name of the dict to the object.

# ```julia
# using TidierFiles
# file = read_rdata("path.rdata) # or read_file("path.rdata)
# df = file["entry_name"]
# ```

# This is in contrast to .rds files which will contain one data frame.
# ```julia
# df = read_rdata("path.rds)
# ```
10 changes: 9 additions & 1 deletion docs/examples/UserGuide/xl.jl
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,12 @@

# - `x`: The data to write. Can be a single `Pair{String, DataFrame}` for writing one sheet, or a `Tuple` of such pairs for writing multiple sheets. The `String` in each pair specifies the sheet name, and the `DataFrame` is the data to write to that sheet.
# - `path`: The path to the output Excel file.
# - `overwrite`: Whether to overwrite an existing file. Default is `false`.
# - `overwrite`: Whether to overwrite an existing file. Default is `false`.

# ## Writing to a specific sheet
# The example below demonstrates how to write to specific sheets in a file.
# The string in the `Dict` is the sheet name, it can be new or preexisting. The second component is the dataframe to be written to that sheet.
# In this example, two sheets, "REPORT_A" and "REPORT_C" are being written to with `df` and `df2` respectively.
# ```julia
# write_xlsx(("REPORT_A" => df, "REPORT_C" => df2); path = "/Users/danielrizk/Downloads/xlsxtest2.xlsx", overwrite = true)
# ```
1 change: 1 addition & 0 deletions docs/mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -121,4 +121,5 @@ nav:
- "Stats Files": "examples/generated/UserGuide/stats.md"
- "Arrow Files": "examples/generated/UserGuide/Arrow.md"
- "Parquet Files": "examples/generated/UserGuide/parquet.md"
- "R Data Files": "examples/generated/UserGuide/r_files.md"
- "Reference" : "reference.md"
4 changes: 4 additions & 0 deletions docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ Currently supported file types:
- `read_dta` and `write_dta` (.dta)
- `read_arrow` and `write_arrow`
- `read_parquet` and `write_parquet`
- `read_rdata` (.rdata and .rds)

Agnostic read and write functions that detect the type and dispatch the appropriate function.
- `read_file` and `write_file`

# Examples

Expand Down
6 changes: 5 additions & 1 deletion src/TidierFiles.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@ using ReadStatTables
using Reexport
using Parquet2
using Arrow
using RData

@reexport using DataFrames: DataFrame

export read_csv, write_csv, read_tsv, write_tsv, read_table, write_table, read_delim, read_xlsx, write_xlsx,
read_fwf, write_fwf, fwf_empty, fwf_positions, fwf_positions, read_sav, read_sas, read_dta, write_sav, write_sas,
write_dta, read_arrow, write_arrow, read_parquet, write_parquet, read_csv2
write_dta, read_arrow, write_arrow, read_parquet, write_parquet, read_csv2, read_file, write_file, read_rdata


include("docstrings.jl")
Expand All @@ -23,6 +24,7 @@ include("xlfiles.jl")
include("statsfiles.jl")
include("parquet_files.jl")
include("arrow_files.jl")
include("r_data.jl")

"""
$docstring_read_csv
Expand Down Expand Up @@ -444,4 +446,6 @@ function write_table(
threaded = num_threads > 1)
end

include("gen_fxn.jl")

end
Loading

2 comments on commit bed8090

@drizk1
Copy link
Member Author

@drizk1 drizk1 commented on bed8090 Aug 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator register

Release notes:

  • adds read_rdata for reading .rds and .rdata files
  • adds read_file and write_file as type agnostic read write functions that dispatch the correct function for any file type

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/113780

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.1.4 -m "<description of version>" bed809034b273ba8b4bd887f001ef6a9ea2141db
git push origin v0.1.4

Please sign in to comment.