Plot values of NASDAQ companies using CSV file
Source code name: "nasdaq_values.py"
Programming language: Python
Topic: Finance/Plots
DMelt Version 1.4. Last modified: 08/22/1973. License: Pro
https://datamelt.org/code/cache/nasdaq_values_4520.py
To run this script using the DMelt IDE, copy the above URL link to the menu [File]→[Read script from URL] of the DMelt IDE.


# Shows how to read CSV files from the web, process it, and make a histogram of NASDAQ values 

from jhplot import *
from java.awt import Color

print Web.get("https://www.nasdaq.com/screening/companies-by-name.aspx?letter=0&exchange=nasdaq&render=download", "nasdaq.csv", False)

c1 = HPlot("Canvas",600,400)
c1.getAntiAlias()
c1.setGTitle("Value in billions")
c1.visible()

# set range
c1.setRangeX(0.1,200)
c1.setLogScale(0,1)
# set autorange
#c1.setAutoRange()

h1 = H1D("Technology companies from NASDAQ list",500, 0.1, 200.0)
h1.setFill(1)
h1.setErrX(0)
h1.setErrY(1)
h1.setFillColorTransparency(0.7)
h1.setFillColor(Color.red)
h1.setColor(Color.red)
h1.setErrColorY(Color.blue)
c1.setNameX("Billions of dollars")
c1.setNameY("Technology companies")

n=0
from jhplot.io.csv import *
r=CSVReader("nasdaq.csv",',')
while 1:
 line= r.readNext()
 if line == None: break
 if line[5] != "Technology": continue # look at Technology stock
 if (line[3].find("B") <0): continue  # look at B$ technology stocks 
 value=line[3].replace('B','')
 value=value.replace('$','')
 print n, line
 h1.fill(float(value))
 n= n+1
r.close()

c1.draw(h1)



You see the box below because you did not login.