User:Emily/Prototyping/Trimester 03/05: Difference between revisions

From XPUB & Lens-Based wiki
(Created page with "Page Link: http://pzwart1.wdka.hro.nl/~yuzhen/p_js/ Steps: :Python words sorting (import sys, re, json) -- to create json file - sys.stdin.read() '''read file via < in comm...")
 
No edit summary
 
(One intermediate revision by the same user not shown)
Line 11: Line 11:
  var = open("filename.json")
  var = open("filename.json")
  data = json.load(var)
  data = json.load(var)
var = open ("filename.html", "w")
  var.write()
  var.write()
  var.close()
  var.close()
   
   
  var = open ("filename.html", "w")
in the html page
  d3.json use selector
.style("color", function () {
    return d3.hsl(Math.random()*360, 1.0, 0.5);


: I made page reload via meta ...to view different result
: I made page reload via meta ...to view different result
----
To make each word in single pages:
f = open ("filename/word{0:06d}.html".format(var), "w")
page = """<a href="word{2:06d}.html" style="font-size: {1}em">{0}</a>""".format(d['word'], d['count'], random.randint(0, len(data)))
f.write(page)
f.close()

Latest revision as of 11:32, 19 June 2015

Page Link: http://pzwart1.wdka.hro.nl/~yuzhen/p_js/

Steps:

Python words sorting (import sys, re, json) -- to create json file
- sys.stdin.read() read file via < in command line
- find words, using regular expression, (r"\b(\w+)\b"
- sorting, there are .sort module in python
- print json.dumps(output, indent=2)
Python make html (import json, random)
var = open("filename.json")
data = json.load(var)
var = open ("filename.html", "w")
var.write()
var.close()

in the html page

d3.json use selector
.style("color", function () {
    return d3.hsl(Math.random()*360, 1.0, 0.5);
I made page reload via meta ...to view different result

To make each word in single pages:

f = open ("filename/word{0:06d}.html".format(var), "w")
page = """<a href="word{2:06d}.html" style="font-size: {1}em">{0}</a>""".format(d['word'], d['count'], random.randint(0, len(data)))
f.write(page)
f.close()