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

[WIP] Getting data from local resource #297

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

alhirzel
Copy link

What is the best way to get data from a LocalResource?

For my application, I am treating a Pluto notebook just like a Julia script, and am packaging it alongside some data that is being analyzed. The files are small-medium size, so the data: URI technique employed by this package is an ideal fit for export to HTML later.

One of the files is a .csv file, and I need to parse it. Currently, I am doing something like this with the help of a new method currently in this PR as a straw-man:

f = PlutoUI.LocalResource("data.csv")
d = CSV.read(Vector{UInt8}(f), DataFrame)

(One problem with this approach is that it will only work for Resources that are generated using the LocalResource function; perhaps the type should be forked?)

Happy to implement something and propose it here, but I am wondering if there are better ways to do what I am trying to do. Ideas:

  1. integrate with the FileIO.jl package
  2. use the PlutoUI.as_text function in a way I don't yet understand
  3. use something like the RelocatableFolders.jl package (a la PackageCompiler)
  4. use another approach not involving LocalResource - e.g. if it is going to be deprecated or externalized in the future

Copy link

Try this Pull Request!

Open Julia and type:

julia> import Pkg
julia> Pkg.activate(temp=true)
julia> Pkg.add(url="https://github.com/alhirzel/PlutoUI.jl", rev="data-from-LocalResources")
julia> using PlutoUI

Or run this code in your browser: Run with binder

@alhirzel alhirzel marked this pull request as draft February 24, 2024 16:31
@fonsp
Copy link
Member

fonsp commented Apr 24, 2024

Hey @alhirzel !

Sorry I missed your message before!

Can you write a bit more about why you cannot access the files normally? E.g.

CSV.read(read("data.csv"), DataFrame)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants