Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add gen reader #17

Merged
merged 3 commits into from
Aug 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading