Importing csv file in VS Code, with p5js library - csv

I am using p5js library in VS Code and trying to import a csv file to put into an array.
I have tried using the preload function, but it is not loading. It works perfectly when using the online p5js editor. I am wondering if I have entered the link to the file incorrectly - Does it need to be structured differently in VS code? I have tried with and without the name of my folder included.
This is my code below:
function preload() {
table = loadTable('activity.csv', 'csv', 'header');
}

Related

Create HTML file of a generated PDF file (fpdf2) using Python

I am trying to create an HTML file of a PDF output generated by fpdf2 using Python packages. My code for creating the PDF is the following, which saves the PDF in my local disk:
from fpdf import FPDF
pdf = FPDF()
####my code for putting content (text, image, table) in the pdf
pdf.output(file_savingpath, "F")
Does anyone have a minimal working solution to create an automated HTML file creation solution using Python 3.x?
Best,
Debayan

How can I parse a link within locally stored html using python?

I am trying to extract text from a link within an html file that is locally stored. The link is as follows:
file:///Users/my_name/Dropbox/folder_name/wisenews/18Jan2021%20(1).html#body.202003310521728.1
I can't seem to use open() to access this link. I tried the following but does not work.
open(file:///Users/my_name/Dropbox/folder_name/wisenews/18Jan2021%20(1).html#body.202003310521728.1)
How can I access this link?
I added screenshots of jupyter notebook for more elaboration
You have to pass the actual file path to the function
Should be something like:
open("C:/Users/Users/my_name/Dropbox/folder_name/wisenews/18Jan2021%20(1).html")

dimple.js example chart not loading

I am having trouble loading the example code from dimple.js for the following chart:
http://dimplejs.org/advanced_examples_viewer.html?id=advanced_storyboard_control
The only change I made is to save it as a .csv instead of .tsv.
The code (index.html) is saved as:
"C:\website\public\index.html"
and the datafile is saved as:
"C:\website\public\data\example_data.csv"
Any reasons this wouldn't load?
Note: dimple example data file can be retrieved from: http://dimplejs.org/data/example_data.tsv
My code in index.html is exactly as the code from the dimple example page
except for the reference to the data file in line 7, I use:
d3.csv("/data/example_data.csv", function (data) {
When referencing the .tsv file instead of .csv there is no problem.
StillNot certain why the file format mattered for this, however.

Custom JSON file doesn't work with Highcharts

I'm very new to HighCharts and have a question about integrating JSON files.
I'm attempting to call a JSON file for my HighCharts file, however when I attempt to call it, the chart breaks and nothing is displayed. I am using the base Highcharts code in order to do this.
Here is my JSON input file that I am trying to use:
[
[Date.UTC(2012,00,01),2],
[Date.UTC(2012,00,02),6],
[Date.UTC(2012,00,03),4],
[Date.UTC(2012,00,04),0],
[Date.UTC(2012,00,05),2],
[Date.UTC(2012,00,06),3],
[Date.UTC(2012,00,07),1],
[Date.UTC(2012,00,08),3],
[Date.UTC(2012,00,09),7],
[Date.UTC(2012,00,10),8]
]
I have found other examples which say that it would be better to create an array with the data in it and put it into the JS file, and while that may work now it won't be feasible in the future as the chart will eventually have to reference large JSON files that will be stored in another directory.
Here's a link to the JSFiddle that references the outside JSON file. Any help would be appreciated.

How do I download contents of an html table generated by play 1.2.7 backend on java in xls

I've generated a table using play's #{list} tag and get pretty decent results. Now I need to be able to generate and download an xls version of the table and have no idea what to do. Any pointers at all will be much appreciated
Well you have various options.
Excel will open HTML files. So instead of rendering your table as HTML you can it to stream it to the browser and set the content type as XLS.
While Excel will open it this it will still be an HTML file rather than an XLS(X) document.
You can generate as CSV from your data model and stream this to the browser. Again this will be a CSV rather than a proper XLS(X) document.
There also seem to be some solutions around which can do it using Javscript. See as a starting point: Generate excel sheet from html tables using jquery
Finally you can can use something like Apache POI or JXLS to generate a 'proper' xls(x) document and stream this to the browser. I have some code here that will export HTML to 'proper' xlsx file if this is the route you wish to go. Workflow is then to create some HTML from your data model and use this to convert to Excel rather than having to programmatically build the Excel document using POI. https://github.com/alanhay/html-exporter