HubNet web export files...?

60 views
Skip to first unread message

Shir-May Rapaport

unread,
Aug 25, 2025, 11:52:24 AMAug 25
to netlogo-users
Hi, I hope Im in the right place 😅 , I'm a computer science undergraduate student, and I'm working with an existing NetLogo project ( = Desktop version) and I'm converting it to its web version.
I watched the tutorial video in here - https://hubnetweb.org/docs/converting  , which really helped me! Thanks for that! :) 

But I still need help with something very fundamental - is there a way to export simulation files - after it's finished?

In the desktop version - I exported CSV files, but as far as I understand I can't do this in the web version. (Is that right?)

Is there an alternative way to save the simulation data? 

thank you and have a great day :) 

Michael Tamillow

unread,
Aug 25, 2025, 12:10:35 PMAug 25
to Shir-May Rapaport, netlogo-users
Hey Shir-May, have you checked out the web-extension: https://github.com/NetLogo/Web-Extension/wiki/Primitives

seems to have a download-file primitive you may find useful.

--
You received this message because you are subscribed to the Google Groups "netlogo-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to netlogo-user...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/netlogo-users/44ec2abb-95db-4d86-b53d-2accf03aab37n%40googlegroups.com.

Shir-May Rapaport

unread,
Sep 3, 2025, 10:11:08 AMSep 3
to netlogo-users
thank you :) 
and i have another question, is there any way to attached to here the .nlogo + .json +.hnw.json files from the video of the guide - https://hubnetweb.org/docs/converting ?
Because I'm really, really having trouble adding a plot — a histogram — to the client page role UI that is client-specific and actually works (i.e., shows the data it's supposed to), instead of just staying empty like it is now. And this is after almost a week of trying with ChatGPT and Gemini, and it still doesn't work.   :( 
thank you 


client plots not working.png
ב-יום שני, 25 באוגוסט 2025 בשעה 19:10:35 UTC+3, Michael Tamillow כתב/ה:

Jason Bertsche

unread,
Sep 3, 2025, 6:12:12 PMSep 3
to shir...@gmail.com, netlog...@googlegroups.com

Hi Shir-May,

I'm the one who made HubNet Web and the conversion guide for it.  Thank you for your interest in the project.



is there a way to export simulation files - after it's finished?

In the desktop version - I exported CSV files, but as far as I understand I can't do this in the web version. (Is that right?)

You can export files in NetLogo Web, just not using language primitives like `file-open`.  Code that is running on web pages isn't allowed to talk directly to the user's file system—you can imagine what a problem it would be if any web page you went to could read all the files on your computer.  But there are language extensions available in NetLogo Web that enable you to handle files in ways that web browsers allow.  Unfortunately (and maybe ironically), the Web extension isn't one of them, as it isn't implemented in NetLogo Web.  (The `http-req` extension fills a similar purpose, but isn't API-compatible with desktop's Web extension, and won't help in this situation.)

The main way you should save a file from NetLogo Web is by using the `send-to` extension, which is available in both desktop NetLogo and NetLogo Web.  A very simple example of its usage would be: `send-to:file "my-favorite-fruits.txt" "grapes\napples\noranges\nbananas"`.

Also, you mentioned CSV files.  If it's helpful to you, the CSV extension is available in NetLogo Web.  However, its `to-file` and `from-file` primitives are not implemented on the web.

Finally, it sounds like you're having some difficulties with narrowcast/client-specific plots in HubNet Web.  The canonical example of narrowcast plots is the Oil Cartel model, which you might find helpful as a demonstration of how to do it.  Regardless, if you e-mail me the '.hnw.json' file for your model, I can help with getting your histogram to work.  After the experience of converting all 39 of the HubNet models in the NetLogo Models Library to run in HubNet Web, my bet is that I can figure this one out, too.

Jason Bertsche

Shir-May Rapaport

unread,
Sep 9, 2025, 9:19:48 AMSep 9
to netlogo-users

Hi everyone — thank you all for the responses, and thank you Jason for the very detailed reply 🙏🏻.
That cleared up a lot for me, and I have a few more things:

  • Plots: I did manage to get my narrowcast/client-specific plots working, but they make the simulation very slow. I’ll email you my .hnw.json so you can take a quick look.

  • Exporting data: I’ll try the send-to:file approach for saving the CSV strings from my model. Thanks for confirming that this is the right path on the web.

  • If possible, I’d love to ask for a 5-minute Zoom, just to sanity-check my setup while you skim the .hnw.json. Totally understand if that’s not doable 🙏🏻. I just don’t want to bother you (Jason) with too many emails or long back-and-forth in the forum.(😅 if maybe a quick zoom could resolve it faster.)

Also, a couple of quick clarifications about file export in NetLogo Web:

  1. File size & reliability: Are there practical limits (or browser gotchas) for send-to:file (e.g., tens of MB)? Would you recommend chunking/partitioning long “run” logs?

  2. Filenames & UX: Is there a recommended pattern to ensure the browser keeps the suggested name (like logger_world_init_data_YYYYMMDD_HHMMSS.csv), or should I expect a rename prompt in some browsers?

  3. Multiple saves per session: Do browsers require a fresh user gesture for each send-to:file save, or can two saves (INIT and RUN) happen back-to-back from one button click?

  4. Cloud upload from model: Is there any recommended way to upload directly to a server (e.g., Google Apps Script → Drive) from NetLogo Web? I know the web: extension isn’t implemented — is http-req viable for POSTing raw CSV, or is the best practice to just use send-to:file and let the wrapper/page handle uploads?

Thanks again for all your help and for HubNet Web itself — it’s awesome. 🙏🏻
 I’ll send the .hnw.json right away. :)   

Best,
Shir-May


ב-יום חמישי, 4 בספטמבר 2025 בשעה 01:12:12 UTC+3, Jason Bertsche כתב/ה:

Jason Bertsche

unread,
Sep 9, 2025, 4:25:02 PMSep 9
to netlog...@googlegroups.com

File size & reliability: Are there practical limits (or browser gotchas) for send-to:file (e.g., tens of MB)? Would you recommend chunking/partitioning long “run” logs?

Chunking is probably a good idea if your files get particularly large.  NetLogo Web ought to be able to handle larger files, but, in my experience, asking it to save a single string that's a megabyte in size or more will lead to unsteady performance.

Filenames & UX: Is there a recommended pattern to ensure the browser keeps the suggested name (like logger_world_init_data_YYYYMMDD_HHMMSS.csv), or should I expect a rename prompt in some browsers?

Both Firefox and Chrome seem to respect the file name that I provide to `send-to:file`, so I think that you're fine on that front.



Multiple saves per session: Do browsers require a fresh user gesture for each send-to:file save, or can two saves (INIT and RUN) happen back-to-back from one button click?

That's up to the browser.  Firefox allows two downloads from the same user action, but Chrome only allows one before popping up a dialog asking if you want to allow multiple downloads.  I haven't tested on Safari, but I would also expect them to only allow one.



Cloud upload from model: Is there any recommended way to upload directly to a server (e.g., Google Apps Script → Drive) from NetLogo Web? I know the web: extension isn’t implemented — is http-req viable for POSTing raw CSV, or is the best practice to just use send-to:file and let the wrapper/page handle uploads?

If I wanted to gather logs in NetLogo Web, yeah, the first thing I would try would be `http-req:post`.  The syntax is `http-req:post url body contentType` (all arguments are strings).

I'll follow up about the other things.

Jason Bertsche

Reply all
Reply to author
Forward
0 new messages