0

In a Jupiter notebook I got some csv from google drive links and then made some data visualizations. The code I used for getting the data is this:

!wget "https://firebasestorage.googleapis.com/v0/b/scrapper-6e7db.appspot.com/o/modified_publicationRecord_with_institute_no_depart.csv?alt=media&token=26fe21ba-1d5c-4599-895c-ac953de63ca1" -O "modified_publicationRecord_with_institute_no_depart.csv" !wget

In Jupyter it then downloads this and gets the csv. Now I have to do the same thing with Quarto in RStudio. If I enter the code in a python block it gives me some errors:

> reticulate::repl_python()
>>> ```{python}
  File "<string>", line 1
    ```{python}
    ^
SyntaxError: invalid syntax
>>> # downloading dataset...
>>> !wget "https://firebasestorage.googleapis.com/v0/b/scrapper-6e7db.appspot.com/o/modified_publicationRecord_with_institute_no_depart.csv?alt=media&token=26fe21ba-1d5c-4599-895c-ac953de63ca1" -O "modified_publicationRecord_with_institute_no_depart.csv"
Warning: error in running command>>> !wget "https://firebasestorage.googleapis.com/v0/b/scrapper-6e7db.appspot.com/o/orcidxofs_2.csv?alt=media&token=42dfbaa2-cd60-43c8-8986-e0a75f5e28b1" -O "orcidxofs_2.csv"
sh: wget: command not found
sh: wget: command not found
Warning: error in running command>>> !wget "https://firebasestorage.googleapis.com/v0/b/scrapper-6e7db.appspot.com/o/groups_hierarchy.csv?alt=media&token=530bec2a-a881-4582-8713-e72f4b632592" -O "groups_hierarchy.csv"
sh: wget: command not found
Warning: error in running command>>> !wget "https://firebasestorage.googleapis.com/v0/b/scrapper-6e7db.appspot.com/o/resultDbMain.csv?alt=media&token=9ab74838-9f90-478b-8831-4a6b60b1b40d" -O "resultDbMain.csv"
sh: wget: command not found
Warning: error in running command>>> ```
  File "<string>", line 1
    ```
    ^
SyntaxError: invalid syntax
>>> 
>>> quit
> ``` python
Error: attempt to use zero-length variable name

So what's the problem with that.

I just entered the same code in a python code chunk in quarto and got an error. I also tried to delete the "``` python" since it seems that the error says that is not needed. But for sure this is needed.

Gugu72
  • 2,052
  • 13
  • 35
Can Kilic
  • 19
  • 3
  • 3
    `!wget` isn't Python code. The exclamation mark is telling the notebook to run `wget` in your shell: https://stackoverflow.com/questions/53498226/what-is-the-meaning-of-exclamation-and-question-marks-in-jupyter-notebook You also may not have `wget` installed as suggested by `sh: wget: command not found` – Dallan Aug 29 '23 at 14:00
  • so is it even possible to execute this wget code in quarto? couldn't find anything in google – Can Kilic Aug 29 '23 at 14:33
  • More specifically, it is ipython code and not python code. IPython came after Python by adding conveniences such as that to send commands to the shell. Then IPython notebook combined IPython in a GUI and then when the developers added the ability to run other kernels IPython Notebook evolved into the Jupyter project. Jupyter inherits a lot of those conveniences from IPython. Is it possible to run IPython code via reticulate or just pure python? Did you try running via reticulate `os.system("wget -h")`after running `import os`? If that works, you can edit the command to fetch what you want. – Wayne Aug 29 '23 at 14:40
  • On a different tack, if you are in RStudio then perhaps you can use R-based methods, in this case `download.file(url, destfile)` outlined [here](https://statisticsglobe.com/download-file-in-r-example)? However, maybe you are trying to stick with Python in Quarto. I haven't used Quarto much & not at all in RStudio and so some of my suggestions to try or consider, other than `os.system()`, are just that. The `os.system()` then the method to use that to run wget should work. By the way, my suggested test `os.system("wget -h")` may not return anything but hopefully triggers no error like you see. – Wayne Aug 29 '23 at 14:50

0 Answers0