Data update

This commit is contained in:
Ingy döt Net 2026-04-30 12:34:36 -04:00
parent 4bb20c9b71
commit cbaf4c4b64
12390 changed files with 318560 additions and 27248 deletions

View file

@ -0,0 +1,19 @@
with Ada.Strings.Unbounded;
generic
type Item_Type is private;
with function To_String(Item: Item_Type) return String is <>;
with procedure Put(S: String) is <>;
with procedure Put_Line(Line: String) is <>;
package HTML_Table is
subtype U_String is Ada.Strings.Unbounded.Unbounded_String;
function Convert(S: String) return U_String renames
Ada.Strings.Unbounded.To_Unbounded_String;
type Item_Array is array(Positive range <>, Positive range <>) of Item_Type;
type Header_Array is array(Positive range <>) of U_String;
procedure Print(Items: Item_Array; Column_Heads: Header_Array);
end HTML_Table;

View file

@ -0,0 +1,56 @@
package body HTML_Table is
procedure Print(Items: Item_Array; Column_Heads: Header_Array) is
function Blanks(N: Natural) return String is
-- indention for better readable HTML
begin
if N=0 then
return "";
else
return " " & Blanks(N-1);
end if;
end Blanks;
procedure Print_Row(Row_Number: Positive) is
begin
Put(Blanks(4) & "<tr><td>" & Positive'Image(Row_Number) & "</td>");
for I in Items'Range(2) loop
Put("<td>" & To_String(Items(Row_Number, I)) & "</td>");
end loop;
Put_Line("</tr>");
end Print_Row;
procedure Print_Body is
begin
Put_Line(Blanks(2)&"<tbody align = ""right"">");
for I in Items'Range(1) loop
Print_Row(I);
end loop;
Put_Line(Blanks(2)&"</tbody>");
end Print_Body;
procedure Print_Header is
function To_Str(U: U_String) return String renames
Ada.Strings.Unbounded.To_String;
begin
Put_Line(Blanks(2) & "<thead align = ""right"">");
Put(Blanks(4) & "<tr><th></th>");
for I in Column_Heads'Range loop
Put("<td>" & To_Str(Column_Heads(I)) & "</td>");
end loop;
Put_Line("</tr>");
Put_Line(Blanks(2) & "</thead>");
end Print_Header;
begin
if Items'Length(2) /= Column_Heads'Length then
raise Constraint_Error with "number of headers /= number of columns";
end if;
Put_Line("<table>");
Print_Header;
Print_Body;
Put_Line("</table>");
end Print;
end HTML_Table;

View file

@ -0,0 +1,32 @@
with Ada.Text_IO, Ada.Numerics.Discrete_Random, HTML_Table;
procedure Test_HTML_Table is
-- define the Item_Type and the random generator
type Four_Digits is mod 10_000;
package Rand is new Ada.Numerics.Discrete_Random(Four_Digits);
Gen: Rand.Generator;
-- now we instantiate the generic package HTML_Table
package T is new HTML_Table
(Item_Type => Four_Digits,
To_String => Four_Digits'Image,
Put => Ada.Text_IO.Put,
Put_Line => Ada.Text_IO.Put_Line);
-- define the object that will the values that the table contains
The_Table: T.Item_Array(1 .. 4, 1..3);
begin
-- fill The_Table with random values
Rand.Reset(Gen);
for Rows in The_Table'Range(1) loop
for Cols in The_Table'Range(2) loop
The_Table(Rows, Cols) := Rand.Random(Gen);
end loop;
end loop;
-- output The_Table
T.Print(Items => The_Table,
Column_Heads => (T.Convert("X"), T.Convert("Y"), T.Convert("Z")));
end Test_HTML_Table;

View file

@ -0,0 +1,11 @@
<table>
<thead align = "right">
<tr><th></th><td>X</td><td>Y</td><td>Z</td></tr>
</thead>
<tbody align = "right">
<tr><td> 1</td><td> 7255</td><td> 3014</td><td> 9436</td></tr>
<tr><td> 2</td><td> 554</td><td> 3314</td><td> 8765</td></tr>
<tr><td> 3</td><td> 4832</td><td> 129</td><td> 2048</td></tr>
<tr><td> 4</td><td> 31</td><td> 6897</td><td> 8265</td></tr>
</tbody>
</table>

View file

@ -0,0 +1,31 @@
on pad_table(s, char2)
set opener to "<t" & char2 & ">"
set closer to "</t" & char2 & ">"
repeat with i from 1 to length of s
set x to item i of s
set item i of s to opener & x & closer
end repeat
return "<tr>" & s & "</tr>"
end pad_table
on gen_row(n, ncols)
set row to {n}
repeat ncols times
set row to row & (random number from 1 to 9999)
end repeat
return row
end gen_row
on html_table(headings, nrows)
set ncols to length of headings
set theader to pad_table({""} & headings, "h")
set tbody to {}
repeat with i from 1 to nrows
set tbody to tbody & pad_table(gen_row(i, ncols), "d")
end repeat
set out to {"<table>"} & theader & tbody & {"</table>"}
set AppleScript's text item delimiters to linefeed
return out as text
end html_table
html_table({"X", "Y", "Z"}, 3)

View file

@ -0,0 +1,115 @@
IDENTIFICATION DIVISION.
PROGRAM-ID. Table.
AUTHOR. Bill Gunshannon.
INSTALLATION. Home.
DATE-WRITTEN. 1 January 2022.
************************************************************
** Program Abstract:
** Data values are hardcoded in this example but they
** could come from anywhere. Computed, read from a
** file, input from the keyboard.
************************************************************
ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT Table-File ASSIGN TO "index.html"
ORGANIZATION IS LINE SEQUENTIAL.
DATA DIVISION.
FILE SECTION.
FD Table-File
DATA RECORD IS Table-Record.
01 Table-Record.
05 Field1 PIC X(80).
WORKING-STORAGE SECTION.
01 Table-Data.
05 Line3.
10 Line3-Value1 PIC S9(4) VALUE 1234.
10 Line3-Value2 PIC S9(4) VALUE 23.
10 Line3-Value3 PIC S9(4) VALUE -123.
05 Line4.
10 Line4-Value1 PIC S9(4) VALUE 123.
10 Line4-Value2 PIC S9(4) VALUE 12.
10 Line4-Value3 PIC S9(4) VALUE -1234.
05 Line5.
10 Line5-Value1 PIC S9(4) VALUE 567.
10 Line5-Value2 PIC S9(4) VALUE 6789.
10 Line5-Value3 PIC S9(4) VALUE 3.
01 Table-HTML.
05 Line1 PIC X(16) VALUE
"<table border=1>".
05 Line2 PIC X(40) VALUE
"<th></th><th>X</th><th>Y</th><th>Z</th>".
05 Line3.
10 Line3-Field1 PIC X(31) VALUE
"<tr align=center><th>1</th><td>".
10 Line3-Value1 PIC -ZZZ9.
10 Line3-Field3 PIC X(9) VALUE
"</td><td>".
10 Line3-Value2 PIC -ZZZ9.
10 Line3-Field5 PIC X(9) VALUE
"</td><td>".
10 Line3-Value3 PIC -ZZZ9.
10 Line3-Field5 PIC X(10) VALUE
"</td></tr>".
05 Line4.
10 Line4-Field1 PIC X(31) VALUE
"<tr align=center><th>2</th><td>".
10 Line4-Value1 PIC -ZZZ9.
10 Line4-Field3 PIC X(9) VALUE
"</td><td>".
10 Line4-Value2 PIC -ZZZ9.
10 Line4-Field5 PIC X(9) VALUE
"</td><td>".
10 Line4-Value3 PIC -ZZZ9.
10 Line4-Field5 PIC X(10) VALUE
"</td></tr>".
05 Line5.
10 Line5-Field1 PIC X(31) VALUE
"<tr align=center><th>3</th><td>".
10 Line5-Value1 PIC -ZZZ9.
10 Line5-Field3 PIC X(9) VALUE
"</td><td>".
10 Line5-Value2 PIC -ZZZ9.
10 Line5-Field5 PIC X(9) VALUE
"</td><td>".
10 Line5-Value3 PIC -ZZZ9.
10 Line5-Field5 PIC X(10) VALUE
"</td></tr>".
05 Line6 PIC X(8) VALUE
"</table>".
PROCEDURE DIVISION.
Main-Program.
OPEN OUTPUT Table-File.
MOVE CORRESPONDING Table-Data TO Table-HTML.
PERFORM Write-Table.
CLOSE Table-File.
STOP RUN.
Write-Table.
WRITE Table-Record FROM Line1 OF Table-HTML
AFTER ADVANCING 1 LINE.
WRITE Table-Record FROM Line2 OF Table-HTML
AFTER ADVANCING 1 LINE.
WRITE Table-Record FROM Line3 OF Table-HTML
AFTER ADVANCING 1 LINE.
WRITE Table-Record FROM Line4 OF Table-HTML
AFTER ADVANCING 1 LINE.
WRITE Table-Record FROM Line5 OF Table-HTML
AFTER ADVANCING 1 LINE.
WRITE Table-Record FROM Line6 OF Table-HTML
AFTER ADVANCING 1 LINE.
END-PROGRAM.

View file

@ -7,8 +7,8 @@ print ""
for r to 3
write "<tr align=right><td>" & r
for c to 3
write "<td>" & random 200
write "<td>" & random 1 200
.
print ""
.
print "</table>"
print ""

View file

@ -0,0 +1,10 @@
puts(1,"<table>\n")
puts(1," <tr><th></th><th>X</th><th>Y</th><th>Z</th></tr>\n")
for i = 1 to 3 do
printf(1," <tr><td>%d</td>",i)
for j = 1 to 3 do
printf(1,"<td>%d</td>",rand(10000))
end for
puts(1,"</tr>\n")
end for
puts(1,"</table>")

View file

@ -0,0 +1,6 @@
<table>
<tr><th></th><th>X</th><th>Y</th><th>Z</th></tr>
<tr><td>1</td><td>7978</td><td>7376</td><td>2382</td></tr>
<tr><td>2</td><td>3632</td><td>1947</td><td>8900</td></tr>
<tr><td>3</td><td>4098</td><td>1563</td><td>2762</td></tr>
</table>

View file

@ -0,0 +1,10 @@
# Converts Microsoft .NET Framework objects into HTML that can be displayed in a Web browser.
ConvertTo-Html -inputobject (Get-Date)
# Create a PowerShell object using a HashTable
$object = [PSCustomObject]@{
'A'=(Get-Random -Minimum 0 -Maximum 10);
'B'=(Get-Random -Minimum 0 -Maximum 10);
'C'=(Get-Random -Minimum 0 -Maximum 10)}
$object | ConvertTo-Html

View file

@ -0,0 +1,25 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>HTML TABLE</title>
</head><body>
<table>
<colgroup><col/><col/><col/><col/><col/><col/><col/><col/><col/><col/><col/><col/><col/><col/><col/></colgroup>
<tr><th>DisplayHint</th><th>DateTime</th><th>Date</th><th>Day</th><th>DayOfWeek</th><th>DayOfYear</th><th>Hour</th><th>Kind</th><th>Milliseco
nd</th><th>Minute</th><th>Month</th><th>Second</th><th>Ticks</th><th>TimeOfDay</th><th>Year</th></tr>
<tr><td>DateTime</td><td>Sunday, October 26, 2014 2:32:31 PM</td><td>10/26/2014 12:00:00 AM</td><td>26</td><td>Sunday</td><td>299</td><td>14<
/td><td>Local</td><td>563</td><td>32</td><td>10</td><td>31</td><td>635499307515634638</td><td>14:32:31.5634638</td><td>2014</td></tr>
</table>
</body></html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>HTML TABLE</title>
</head><body>
<table>
<colgroup><col/><col/><col/></colgroup>
<tr><th>C</th><th>B</th><th>A</th></tr>
<tr><td>8</td><td>7</td><td>3</td></tr>
</table>
</body></html>

View file

@ -0,0 +1 @@
$object | ConvertTo-Html | Out-File -FilePath $env:temp\test.html ; invoke-item $env:temp\test.html

View file

@ -0,0 +1,15 @@
html_table <- function(headings, nrows){
ncols <- length(headings)
pad_table <- function(s, char2="d"){
pad <- paste0("<t", char2, ">", s, "</t", char2, ">", collapse="")
paste0("<tr>", pad, "</tr>", collapse="")
}
theader <- pad_table(c("", headings), char2="h")
gen_row <- function(n) c(n, sample(9999, ncols))
tbody <- lapply(1:nrows, gen_row) |> sapply(pad_table)
cat("<table>", theader, sep="\n")
writeLines(tbody)
cat("</table>\n")
}
html_table(c("X", "Y", "Z"), 3)

View file

@ -0,0 +1,37 @@
Rebol [
title: "Rosetta code: Create an HTML table"
file: %Create_an_HTML_table.r3
url: https://rosettacode.org/wiki/Create_an_HTML_table
note: "Based on Red language implementation!"
]
table-rows: func [][rejoin [
first-tr newline
rand-tr 1 newline
rand-tr 2 newline
rand-tr 3 newline
rand-tr 4 newline
rand-tr 5 newline
]]
td-data: does [999 + random 9000]
rand-td: does [form-tag 'td td-data]
rand-tr: func [i][rejoin [
form-tag 'tr
rejoin [(form-tag 'td i) rand-td rand-td rand-td]
]]
first-tr: func[][rejoin [
form-tag 'tr rejoin [
form-tag 'th ""
form-tag 'th "X"
form-tag 'th "Y"
form-tag 'th "Z"
]
]]
form-tag: func [tag contents /attr a][
ajoin [
"<" tag (if attr [ajoin [" " a/1 "=" {"} a/2 {"}]]) ">"
contents
"</" tag #">"
]
]
print form-tag 'table table-rows

View file

@ -0,0 +1,7 @@
<table><tr><th></th><th>X</th><th>Y</th><th>Z</th></tr>
<tr><td>1</td><td>2096</td><td>3442</td><td>9408</td></tr>
<tr><td>2</td><td>9679</td><td>3917</td><td>7056</td></tr>
<tr><td>3</td><td>2151</td><td>4356</td><td>9440</td></tr>
<tr><td>4</td><td>2741</td><td>9738</td><td>4967</td></tr>
<tr><td>5</td><td>2377</td><td>7190</td><td>7304</td></tr>
</table>

View file

@ -0,0 +1,40 @@
Set objFSO = CreateObject("Scripting.FileSystemObject")
'Open the input csv file for reading. The file is in the same folder as the script.
Set objInFile = objFSO.OpenTextFile(objFSO.GetParentFolderName(WScript.ScriptFullName) &_
"\in.csv",1)
'Create the output html file.
Set objOutHTML = objFSO.OpenTextFile(objFSO.GetParentFolderName(WScript.ScriptFullName) &_
"\out.html",2,True)
'Write the html opening tags.
objOutHTML.Write "<html><head></head><body>" & vbCrLf
'Declare table properties.
objOutHTML.Write "<table border=1 cellpadding=10 cellspacing=0>" & vbCrLf
'Write column headers.
objOutHTML.Write "<tr><th></th><th>X</th><th>Y</th><th>Z</th></tr>" & vbCrLf
'Go through each line of the input csv file and write to the html output file.
n = 1
Do Until objInFile.AtEndOfStream
line = objInFile.ReadLine
If Len(line) > 0 Then
token = Split(line,",")
objOutHTML.Write "<tr align=""right""><td>" & n & "</td>"
For i = 0 To UBound(token)
objOutHTML.Write "<td>" & token(i) & "</td>"
Next
objOutHTML.Write "</tr>" & vbCrLf
End If
n = n + 1
Loop
'Write the html closing tags.
objOutHTML.Write "</table></body></html>"
objInFile.Close
objOutHTML.Close
Set objFSO = Nothing