1

I have a college assignment to make a simple website. I have a html website with a table and I also have a python program that scrapes another website. It then writes this data to a text file. The data consists of numbers with one number per line and about 28 numbers total.

Basically I would like the data from the python script to be displayed in the HTML table. I have looked for solutions online, however I am limited to using HTML, CSS and JavaScript as this is what the assignment is asking for. Any help on how to go about this?

JWW020
  • 11
  • 1
  • 1
    break it into bite-sized chunks. first be able to update a single cell with a hard-coded number. Then figure how to update cells in each row with the same number. then figure how to load the text file into an array from ajax. then find how to feeds that array to your all-row updater. – dandavis Jun 06 '20 at 21:16

2 Answers2

0

This depends on what framework you are using. I know Flask, so if you are using Flask, try this:

In Python:

return render_template("myFile.html", items=myItemsList)

In HTML Using jinja2:

{% for item in items %}
<td>{{item}}</td>
{% endfor %}
Krishnan Shankar
  • 780
  • 9
  • 29
0

This is pretty easy if you are using python and a framework like Flask or Django to display the data on the web. However, if you are actually limited to using HTML, CSS and Javascript for the viewable website then you'll need to focus on Javascript as the method for reading the text file.

There are some good answers for that here: How to read text file in JavaScript and here Read a local text file using Javascript

Hopefully that helps :)

Michael Romrell
  • 1,026
  • 5
  • 15
  • 31