Start to Finish: A Data Workflow

Powerpoint Slides

Original Datafile Cleaned Datafile

Step Associated Code Output Link to File
1
import sys

xmlFileLocation = '.\\OriginalXML-Step2.txt'

xmlFileHandle = open(xmlFileLocation, 'r')

xmlFileHandle.close()
sys.exit(0)
Python 3.10.0 (tags/v3.10.0:b494f59, Oct  4 2021, 19:00:18) [MSC v.1929 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license()" for more information.

=== RESTART: Z:\B\Career\2021OUTeachingPresentation\PsuedoXMLParser-Step1.py ===
Step 1.py
2
import sys

xmlFileLocation = '.\\OriginalXML-Step2.txt'
xmlFileHandle = open(xmlFileLocation, 'r')

xmlLines = xmlFileHandle.readlines()

for line in xmlLines:
    print(line)

xmlFileHandle.close()
sys.exit(0)
Python 3.10.0 (tags/v3.10.0:b494f59, Oct  4 2021, 19:00:18) [MSC v.1929 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license()" for more information.

=== RESTART: Z:\B\Career\2021OUTeachingPresentation\PsuedoXMLParser-Step2.py ===
<StudentsTested>

	<StudentGroup>

		<Grade>

			8

		</Grade>

		<Year>

			2006

		</Year>

		<Race>

			Asian

		</Race>

		<NumberTested>

			9593

		</NumberTested>

		<MeanScaleScore>

			675

		</MeanScaleScore>

	</StudentGroup>
<Excessively Long Output Hidden>
	<StudentGroup>

		<Grade>

			8

		</Grade>

		<Year>

			2011

		</Year>

		<Race>

			White

		</Race>

		<NumberTested>

			9570

		</NumberTested>

		<MeanScaleScore>

			688

		</MeanScaleScore>

	</StudentGroup>

</StudentsTested>
Step 2.py
3
import sys

# open file
xmlFileLocation = '.\\OriginalXML-Step2.txt'
xmlFileHandle = open(xmlFileLocation, 'r')

# read file
xmlLines = xmlFileHandle.readlines()

# TODO: Add Code to identify tags and structure, generalize format

# For now, we know the structure of the file, let's process it backwards
xmlLines.pop() # 
xmlMatrix = []
while len(xmlLines) > 1:
    xmlLines.pop() # 
    xmlLines.pop() # 
    StudentGroup = [xmlLines.pop()]
    xmlLines.pop() # 
    xmlLines.pop() # 
    StudentGroup.append(xmlLines.pop())
    xmlLines.pop() # 
    xmlLines.pop() # 
    StudentGroup.append(xmlLines.pop())
    xmlLines.pop() # 
    xmlLines.pop() # 
    StudentGroup.append(xmlLines.pop())
    xmlLines.pop() # 
    xmlLines.pop() # 
    StudentGroup.append(xmlLines.pop())
    xmlLines.pop() # 
    xmlLines.pop() # 
    StudentGroup.reverse()
    xmlMatrix.append(StudentGroup)
# Should leave us with one single 

xmlMatrix.reverse() # It doesn't matter, since the data wasn't ordered, but it doesn't hurt
print(xmlMatrix)

# Close out
xmlFileHandle.close()
sys.exit(0)
Python 3.10.0 (tags/v3.10.0:b494f59, Oct  4 2021, 19:00:18) [MSC v.1929 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license()" for more information.

=== RESTART: Z:\B\Career\2021OUTeachingPresentation\PsuedoXMLParser-Step3.py ===
[['\t\t\t8\n', '\t\t\t2006\n', '\t\t\tAsian\n', '\t\t\t9593\n', '\t\t\t675\n'], ['\t\t
\t8\n', '\t\t\t2007\n', '\t\t\tAsian\n', '\t\t\t9734\n', '\t\t\t681\n'], ['\t\t\t8\n', '\t
\t\t2008\n', '\t\t\tAsian\n', '\t\t\t9964\n', '\t\t\t691\n'], ['\t\t\t8\n', '\t\t\t2009\n',
 '\t\t\tAsian\n', '\t\t\t10385\n', '\t\t\t695\n'], ['\t\t\t8\n', '\t\t\t2010\n', '\t\t
\tAsian\n', '\t\t\t11161\n', '\t\t\t701\n'], ['\t\t\t8\n', '\t\t\t2011\n', '\t\t\tAsian\n',
 '\t\t\t11031\n', '\t\t\t699\n'], ['\t\t\t8\n', '\t\t\t2006\n', '\t\t\tBlack\n', '\t\t
\t25896\n', '\t\t\t628\n'], ['\t\t\t8\n', '\t\t\t2007\n', '\t\t\tBlack\n', '\t\t\t24951\n',
 '\t\t\t636\n'], ['\t\t\t8\n', '\t\t\t2008\n', '\t\t\tBlack\n', '\t\t\t23489\n', '\t\t
\t647\n'], ['\t\t\t8\n', '\t\t\t2009\n', '\t\t\tBlack\n', '\t\t\t23054\n', '\t\t\t658\n'], 
['\t\t\t8\n', '\t\t\t2010\n', '\t\t\tBlack\n', '\t\t\t22445\n', '\t\t\t662\n'], ['\t\t
\t8\n', '\t\t\t2011\n', '\t\t\tBlack\n', '\t\t\t21555\n', '\t\t\t663\n'], ['\t\t\t8\n', '\t
\t\t2006\n', '\t\t\tHispanic\n', '\t\t\t29945\n', '\t\t\t631\n'], ['\t\t\t8\n', '\t\t
\t2007\n', '\t\t\tHispanic\n', '\t\t\t29857\n', '\t\t\t639\n'], ['\t\t\t8\n', '\t\t
\t2008\n', '\t\t\tHispanic\n', '\t\t\t28710\n', '\t\t\t651\n'], ['\t\t\t8\n', '\t\t
\t2009\n', '\t\t\tHispanic\n', '\t\t\t28981\n', '\t\t\t662\n'], ['\t\t\t8\n', '\t\t
\t2010\n', '\t\t\tHispanic\n', '\t\t\t28834\n', '\t\t\t665\n'], ['\t\t\t8\n', '\t\t
\t2011\n', '\t\t\tHispanic\n', '\t\t\t28681\n', '\t\t\t667\n'], ['\t\t\t8\n', '\t\t
\t2006\n', '\t\t\tWhite\n', '\t\t\t10470\n', '\t\t\t660\n'], ['\t\t\t8\n', '\t\t\t2007\n', 
'\t\t\tWhite\n', '\t\t\t9923\n', '\t\t\t666\n'], ['\t\t\t8\n', '\t\t\t2008\n', '\t\t\tWhite
\n', '\t\t\t9871\n', '\t\t\t676\n'], ['\t\t\t8\n', '\t\t\t2009\n', '\t\t\tWhite\n', '\t\t
\t9835\n', '\t\t\t683\n'], ['\t\t\t8\n', '\t\t\t2010\n', '\t\t\tWhite\n', '\t\t\t9963\n',
 '\t\t\t687\n'], ['\t\t\t8\n', '\t\t\t2011\n', '\t\t\tWhite\n', '\t\t\t9570\n', '\t\t
\t688\n']]
Step 3.py
4
import sys

# open file
xmlFileLocation = '.\\OriginalXML-Step2.txt'
xmlFileHandle = open(xmlFileLocation, 'r')

# read file
xmlLines = xmlFileHandle.readlines()

# TODO: Add Code to identify tags and structure, generalize format

# For now, we know the structure of the file, let's process it backwards
xmlLines.pop() # 
xmlMatrix = []
while len(xmlLines) > 1:
    xmlLines.pop() # 
    xmlLines.pop() # 
    StudentGroup = [xmlLines.pop().strip('\t\n')]
    xmlLines.pop() # 
    xmlLines.pop() # 
    StudentGroup.append(xmlLines.pop().strip('\t\n'))
    xmlLines.pop() # 
    xmlLines.pop() # 
    StudentGroup.append(xmlLines.pop().strip('\t\n'))
    xmlLines.pop() # 
    xmlLines.pop() # 
    StudentGroup.append(xmlLines.pop().strip('\t\n'))
    xmlLines.pop() # 
    xmlLines.pop() # 
    StudentGroup.append(xmlLines.pop().strip('\t\n'))
    xmlLines.pop() # 
    xmlLines.pop() # 
    StudentGroup.reverse()
    xmlMatrix.append(StudentGroup)
# Should leave us with one single 
xmlMatrix.reverse() # It doesn't matter, since the data wasn't ordered, but it doesn't hurt

for StudentGroup in xmlMatrix:
    StudentGroup[0] = int(StudentGroup[0])
    StudentGroup[1] = int(StudentGroup[1])
    StudentGroup[3] = int(StudentGroup[3])
    StudentGroup[4] = int(StudentGroup[4])

# Close file
xmlFileHandle.close()

#Construct SQL Query
sqlLines = ["CREATE DATABASE StudentsTested;"]
sqlLines.append("DROP TABLE StudentGroup;")
sqlLines.append("CREATE TABLE StudentGroup (Grade int, Year int, Race varchar(255),
        NumberTested int, MeanScaleScore int);")

# We could do this more efficiently with fewer insert statements, but this is clearer for now
for StudentGroup in xmlMatrix:
    sqlLines.append("INSERT INTO StudentGroup VALUES ("
                    + str(StudentGroup[0]) + ", "
                    + str(StudentGroup[1]) + ", "
                    + "\'" + StudentGroup[2] + "\', "
                    + str(StudentGroup[3]) + ", "
                    + str(StudentGroup[4]) + ");")

print(sqlLines)

#exit
sys.exit(0)
Python 3.10.0 (tags/v3.10.0:b494f59, Oct  4 2021, 19:00:18) [MSC v.1929 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license()" for more information.

=== RESTART: Z:\B\Career\2021OUTeachingPresentation\PsuedoXMLParser-Step4.py ===
['CREATE DATABASE StudentsTested;', 'DROP TABLE StudentGroup;', 'CREATE TABLE StudentGroup 
(Grade int, Year int, Race varchar(255), NumberTested int, MeanScaleScore int);', "INSERT 
INTO StudentGroup VALUES (8, 2006, 'Asian', 9593, 675);", "INSERT INTO StudentGroup VALUES 
(8, 2007, 'Asian', 9734, 681);", "INSERT INTO StudentGroup VALUES (8, 2008, 'Asian', 9964, 
691);", "INSERT INTO StudentGroup VALUES (8, 2009, 'Asian', 10385, 695);", "INSERT INTO 
StudentGroup VALUES (8, 2010, 'Asian', 11161, 701);", "INSERT INTO StudentGroup VALUES (8, 
2011, 'Asian', 11031, 699);", "INSERT INTO StudentGroup VALUES (8, 2006, 'Black', 25896, 
628);", "INSERT INTO StudentGroup VALUES (8, 2007, 'Black', 24951, 636);", "INSERT INTO 
StudentGroup VALUES (8, 2008, 'Black', 23489, 647);", "INSERT INTO StudentGroup VALUES (8, 
2009, 'Black', 23054, 658);", "INSERT INTO StudentGroup VALUES (8, 2010, 'Black', 22445, 
662);", "INSERT INTO StudentGroup VALUES (8, 2011, 'Black', 21555, 663);", "INSERT INTO 
StudentGroup VALUES (8, 2006, 'Hispanic', 29945, 631);", "INSERT INTO StudentGroup VALUES 
(8, 2007, 'Hispanic', 29857, 639);", "INSERT INTO StudentGroup VALUES (8, 2008, 'Hispanic', 
28710, 651);", "INSERT INTO StudentGroup VALUES (8, 2009, 'Hispanic', 28981, 662);", "INSERT 
INTO StudentGroup VALUES (8, 2010, 'Hispanic', 28834, 665);", "INSERT INTO StudentGroup 
VALUES (8, 2011, 'Hispanic', 28681, 667);", "INSERT INTO StudentGroup VALUES (8, 2006, 
'White', 10470, 660);", "INSERT INTO StudentGroup VALUES (8, 2007, 'White', 9923, 666);", 
"INSERT INTO StudentGroup VALUES (8, 2008, 'White', 9871, 676);", "INSERT INTO StudentGroup 
VALUES (8, 2009, 'White', 9835, 683);", "INSERT INTO StudentGroup VALUES (8, 2010, 'White', 
9963, 687);", "INSERT INTO StudentGroup VALUES (8, 2011, 'White', 9570, 688);"]
Step 4.py
5
import sys

# Hard-Coded Values
xmlFileLocation = '.\\OriginalXML-Step2.txt'
DatabaseName = "StudentsTested"
TableName = "StudentGroup"
Attributes = ["Grade", "Year", "Race", "NumberTested", "MeanScaleScore"]

#open and read file
xmlFileHandle = open(xmlFileLocation, 'r')
xmlLines = xmlFileHandle.readlines()

# TODO: Add Code to identify tags and structure, generalize format

# For now, we know the structure of the file, let's process it backwards
xmlLines.pop() # 
xmlMatrix = []
while len(xmlLines) > 1:
    xmlLines.pop() # 
    xmlLines.pop() # 
    StudentGroup = [xmlLines.pop().strip('\t\n')]
    xmlLines.pop() # 
    xmlLines.pop() # 
    StudentGroup.append(xmlLines.pop().strip('\t\n'))
    xmlLines.pop() # 
    xmlLines.pop() # 
    StudentGroup.append(xmlLines.pop().strip('\t\n'))
    xmlLines.pop() # 
    xmlLines.pop() # 
    StudentGroup.append(xmlLines.pop().strip('\t\n'))
    xmlLines.pop() # 
    xmlLines.pop() # 
    StudentGroup.append(xmlLines.pop().strip('\t\n'))
    xmlLines.pop() # 
    xmlLines.pop() # 
    StudentGroup.reverse()
    xmlMatrix.append(StudentGroup)
# Should leave us with one single 
xmlMatrix.reverse() # It doesn't matter, since the data wasn't ordered, but it doesn't hurt

for StudentGroup in xmlMatrix:
    StudentGroup[0] = int(StudentGroup[0])
    StudentGroup[1] = int(StudentGroup[1])
    StudentGroup[3] = int(StudentGroup[3])
    StudentGroup[4] = int(StudentGroup[4])

# Close file
xmlFileHandle.close()

#Construct SQL Query
sqlLines = ["CREATE DATABASE " + DatabaseName + ";"]
sqlLines.append("DROP TABLE " + TableName +";")
sqlLines.append("CREATE TABLE " + TableName + " ("
                + Attributes[0] + " int, "
                + Attributes[1] + " int, "
                + Attributes[2] + " varchar(255), "
                + Attributes[3] + " int, "
                + Attributes[4] + " int);")

# We could do this more efficiently with fewer insert statements, but this is clearer for now
for StudentGroup in xmlMatrix:
    sqlLines.append("INSERT INTO StudentGroup VALUES ("
                    + str(StudentGroup[0]) + ", "
                    + str(StudentGroup[1]) + ", "
                    + "\'" + StudentGroup[2] + "\', "
                    + str(StudentGroup[3]) + ", "
                    + str(StudentGroup[4]) + ");")

print(sqlLines)

#exit
sys.exit(0)
Python 3.10.0 (tags/v3.10.0:b494f59, Oct  4 2021, 19:00:18) [MSC v.1929 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license()" for more information.

=== RESTART: Z:\B\Career\2021OUTeachingPresentation\PsuedoXMLParser-Step5.py ===
['CREATE DATABASE StudentsTested;', 'DROP TABLE StudentGroup;', 'CREATE TABLE StudentGroup 
(Grade int, Year int, Race varchar(255), NumberTested int, MeanScaleScore int);', "INSERT 
INTO StudentGroup VALUES (8, 2006, 'Asian', 9593, 675);", "INSERT INTO StudentGroup VALUES 
(8, 2007, 'Asian', 9734, 681);", "INSERT INTO StudentGroup VALUES (8, 2008, 'Asian', 9964, 
691);", "INSERT INTO StudentGroup VALUES (8, 2009, 'Asian', 10385, 695);", "INSERT INTO 
StudentGroup VALUES (8, 2010, 'Asian', 11161, 701);", "INSERT INTO StudentGroup VALUES (8, 
2011, 'Asian', 11031, 699);", "INSERT INTO StudentGroup VALUES (8, 2006, 'Black', 25896, 
628);", "INSERT INTO StudentGroup VALUES (8, 2007, 'Black', 24951, 636);", "INSERT INTO 
StudentGroup VALUES (8, 2008, 'Black', 23489, 647);", "INSERT INTO StudentGroup VALUES (8, 
2009, 'Black', 23054, 658);", "INSERT INTO StudentGroup VALUES (8, 2010, 'Black', 22445, 
662);", "INSERT INTO StudentGroup VALUES (8, 2011, 'Black', 21555, 663);", "INSERT INTO 
StudentGroup VALUES (8, 2006, 'Hispanic', 29945, 631);", "INSERT INTO StudentGroup VALUES 
(8, 2007, 'Hispanic', 29857, 639);", "INSERT INTO StudentGroup VALUES (8, 2008, 'Hispanic', 
28710, 651);", "INSERT INTO StudentGroup VALUES (8, 2009, 'Hispanic', 28981, 662);", "INSERT 
INTO StudentGroup VALUES (8, 2010, 'Hispanic', 28834, 665);", "INSERT INTO StudentGroup 
VALUES (8, 2011, 'Hispanic', 28681, 667);", "INSERT INTO StudentGroup VALUES (8, 2006, 
'White', 10470, 660);", "INSERT INTO StudentGroup VALUES (8, 2007, 'White', 9923, 666);", 
"INSERT INTO StudentGroup VALUES (8, 2008, 'White', 9871, 676);", "INSERT INTO StudentGroup 
VALUES (8, 2009, 'White', 9835, 683);", "INSERT INTO StudentGroup VALUES (8, 2010, 'White', 
9963, 687);", "INSERT INTO StudentGroup VALUES (8, 2011, 'White', 9570, 688);"]
Step 5.py
6
import sys

# Hard-Coded Values
xmlFileLocation = '.\\OriginalXML-Step2.txt'
sqlFileLocation = '.\\XMLtoSQLOutput.sql'
DatabaseName = "StudentsTested"
TableName = "StudentGroup"
Attributes = ["Grade", "Year", "Race", "NumberTested", "MeanScaleScore"]

#open and read file
xmlFileHandle = open(xmlFileLocation, 'r')
xmlLines = xmlFileHandle.readlines()

# TODO: Add Code to identify tags and structure, generalize format

# For now, we know the structure of the file, let's process it backwards
xmlLines.pop() # 
xmlMatrix = []
while len(xmlLines) > 1:
    xmlLines.pop() # 
    xmlLines.pop() # 
    StudentGroup = [xmlLines.pop().strip('\t\n')]
    xmlLines.pop() # 
    xmlLines.pop() # 
    StudentGroup.append(xmlLines.pop().strip('\t\n'))
    xmlLines.pop() # 
    xmlLines.pop() # 
    StudentGroup.append(xmlLines.pop().strip('\t\n'))
    xmlLines.pop() # 
    xmlLines.pop() # 
    StudentGroup.append(xmlLines.pop().strip('\t\n'))
    xmlLines.pop() # 
    xmlLines.pop() # 
    StudentGroup.append(xmlLines.pop().strip('\t\n'))
    xmlLines.pop() # 
    xmlLines.pop() # 
    StudentGroup.reverse()
    xmlMatrix.append(StudentGroup)
# Should leave us with one single 
xmlMatrix.reverse() # It doesn't matter, since the data wasn't ordered, but it doesn't hurt

for StudentGroup in xmlMatrix:
    StudentGroup[0] = int(StudentGroup[0])
    StudentGroup[1] = int(StudentGroup[1])
    StudentGroup[3] = int(StudentGroup[3])
    StudentGroup[4] = int(StudentGroup[4])

# Close file
xmlFileHandle.close()

#Construct SQL Query
sqlLines = ["CREATE DATABASE " + DatabaseName + ";\n"]
sqlLines.append("DROP TABLE " + TableName +";\n")
sqlLines.append("CREATE TABLE " + TableName + " ("
                + Attributes[0] + " int, "
                + Attributes[1] + " int, "
                + Attributes[2] + " varchar(255), "
                + Attributes[3] + " int, "
                + Attributes[4] + " int);\n")

# We could do this more efficiently with fewer insert statements, but this is clearer for now
for StudentGroup in xmlMatrix:
    sqlLines.append("INSERT INTO StudentGroup VALUES ("
                    + str(StudentGroup[0]) + ", "
                    + str(StudentGroup[1]) + ", "
                    + "\'" + StudentGroup[2] + "\', "
                    + str(StudentGroup[3]) + ", "
                    + str(StudentGroup[4]) + ");\n")

sqlFileHandle = open (sqlFileLocation, 'w')
sqlFileHandle.writelines(sqlLines)
sqlFileHandle.close()

#exit
sys.exit(0)
Python 3.10.0 (tags/v3.10.0:b494f59, Oct  4 2021, 19:00:18) [MSC v.1929 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license()" for more information.

=== RESTART: Z:\B\Career\2021OUTeachingPresentation\PsuedoXMLParser-Step6.py ===
Step 6.py
7
import sys

# Hard-Coded Values
xmlFileLocation = '.\\OriginalXML-Step2.txt'
sqlFileLocation = '.\\XMLtoSQLOutput.sql'
DatabaseName = "StudentsTested"
TableName = "StudentGroup"
Attributes = ["Grade", "Year", "Race", "NumberTested", "MeanScaleScore"]

#open and read file
xmlFileHandle = open(xmlFileLocation, 'r')
xmlLines = xmlFileHandle.readlines()

# TODO: Add Code to identify tags and structure, generalize format

# For now, we know the structure of the file, let's process it backwards
xmlLines.pop() # 
xmlMatrix = []
while len(xmlLines) > 1:
    xmlLines.pop() # 
    xmlLines.pop() # 
    StudentGroup = [xmlLines.pop().strip('\t\n')]
    xmlLines.pop() # 
    xmlLines.pop() # 
    StudentGroup.append(xmlLines.pop().strip('\t\n'))
    xmlLines.pop() # 
    xmlLines.pop() # 
    StudentGroup.append(xmlLines.pop().strip('\t\n'))
    xmlLines.pop() # 
    xmlLines.pop() # 
    StudentGroup.append(xmlLines.pop().strip('\t\n'))
    xmlLines.pop() # 
    xmlLines.pop() # 
    StudentGroup.append(xmlLines.pop().strip('\t\n'))
    xmlLines.pop() # 
    xmlLines.pop() # 
    StudentGroup.reverse()
    xmlMatrix.append(StudentGroup)
# Should leave us with one single 
xmlMatrix.reverse() # It doesn't matter, since the data wasn't ordered, but it doesn't hurt

for StudentGroup in xmlMatrix:
    StudentGroup[0] = int(StudentGroup[0])
    StudentGroup[1] = int(StudentGroup[1])
    StudentGroup[3] = int(StudentGroup[3])
    StudentGroup[4] = int(StudentGroup[4])

# Close file
xmlFileHandle.close()

# Construct SQL Query
# Skip 8 lines to avoid error.  TODO: Generalize this code.
# sqlLines = ["CREATE DATABASE " + DatabaseName + ";\n"]
# sqlLines.append("DROP TABLE " + TableName +";\n")
# sqlLines.append("CREATE TABLE " + TableName + " ("
#                 + Attributes[0] + " int, "
#                 + Attributes[1] + " int, "
#                 + Attributes[2] + " varchar(255), "
#                 + Attributes[3] + " int, "
#                 + Attributes[4] + " int);\n")
sqlLines = ["TRUNCATE TABLE " + TableName + ";\n"]

# We could do this more efficiently with fewer insert statements, but this is clearer for now
for StudentGroup in xmlMatrix:
    sqlLines.append("INSERT INTO StudentGroup VALUES ("
                    + str(StudentGroup[0]) + ", "
                    + str(StudentGroup[1]) + ", "
                    + "\'" + StudentGroup[2] + "\', "
                    + str(StudentGroup[3]) + ", "
                    + str(StudentGroup[4]) + ");\n")

sqlFileHandle = open (sqlFileLocation, 'w')
sqlFileHandle.writelines(sqlLines)
sqlFileHandle.close()

#exit
sys.exit(0)
Python 3.10.0 (tags/v3.10.0:b494f59, Oct  4 2021, 19:00:18) [MSC v.1929 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license()" for more information.

=== RESTART: Z:\B\Career\2021OUTeachingPresentation\PsuedoXMLParser-Step7.py ===
Step 7.py
8
<HTML>
 <HEAD>
  <TITLE>
   TestEnv for SQL compatibility
  </TITLE> 
</HEAD>
 <BODY>
  <H1> Test Environment for Data to Python Data Structure to SQL to HTML </H1>
 </BODY>
</HTML>

Test Environment for Data to Python Data Structure to SQL to HTML

Step 8.html
9
<HTML>
 <HEAD>
  <TITLE>
   TestEnv for SQL compatibility
  </TITLE> 
</HEAD>
 <BODY>
  <H1> Test Environment for Data to Python Data Structure to SQL to HTML </H1>

<?php
// Connection Data
 $srv = "localhost";
 $usr = "root";
 $pwd = ""; // set in MariaDB my.ini, but no password by default
 $db = "studentstested";

// Connect to the server, no password.
 $con = new mysqli($srv, $usr, $pwd, $db);

// Our query right now is simple.
 $qry = "SELECT * FROM studentgroup";
 $out = $con->query($qry);

// Print the output data to the screen.
echo "<TABLE>\n";
while ($row = $out->fetch_assoc())
{
	echo "<TR>\n";
	foreach ($row as $dat)
	{
		echo "<TD>";
		echo $dat;
		echo "</TD>\n";
	}
	echo "</TR>\n"; 
}
echo "</TABLE>\n";
?>
 </BODY>
</HTML>

Test Environment for Data to Python Data Structure to SQL to HTML

8 2006 Asian 9593 675
8 2007 Asian 9734 681
8 2008 Asian 9964 691
8 2009 Asian 10385 695
8 2010 Asian 11161 701
8 2011 Asian 11031 699
8 2006 Black 25896 628
8 2007 Black 24951 636
8 2008 Black 23489 647
8 2009 Black 23054 658
8 2010 Black 22445 662
8 2011 Black 21555 663
8 2006 Hispanic 29945 631
8 2007 Hispanic 29857 639
8 2008 Hispanic 28710 651
8 2009 Hispanic 28981 662
8 2010 Hispanic 28834 665
8 2011 Hispanic 28681 667
8 2006 White 10470 660
8 2007 White 9923 666
8 2008 White 9871 676
8 2009 White 9835 683
8 2010 White 9963 687
8 2011 White 9570 688
Step 9.php (Sort of)
10
<HTML>
 <HEAD>
  <TITLE>
   TestEnv for SQL compatibility
  </TITLE> 
</HEAD>
 <BODY>
  <H1> Test Environment for Data to Python Data Structure to SQL to HTML </H1>

  <p><a href=".\PsuedoXMLParser.py">Regenerate SQL Code</a></p>

<?php
// Connection Data
 $srv = "localhost";
 $usr = "root";
 $pwd = ""; // set in MariaDB my.ini, but no password by default
 $db = "studentstested";

// Connect to the server, no password.
 $con = new mysqli($srv, $usr, $pwd, $db);

// Our query right now is simple.
 $qry = "SELECT * FROM studentgroup";
 $out = $con->query($qry);

// Print the output data to the screen.
echo "<TABLE>\n";
while ($row = $out->fetch_assoc())
{
	echo "<TR>\n";
	foreach ($row as $dat)
	{
		echo "<TD>";
		echo $dat;
		echo "</TD>\n";
	}
	echo "</TR>\n"; 
}
echo "</TABLE>\n";
?>
 </BODY>
</HTML>

Test Environment for Data to Python Data Structure to SQL to HTML

Regenerate SQL Code

8 2006 Asian 9593 675
8 2007 Asian 9734 681
8 2008 Asian 9964 691
8 2009 Asian 10385 695
8 2010 Asian 11161 701
8 2011 Asian 11031 699
8 2006 Black 25896 628
8 2007 Black 24951 636
8 2008 Black 23489 647
8 2009 Black 23054 658
8 2010 Black 22445 662
8 2011 Black 21555 663
8 2006 Hispanic 29945 631
8 2007 Hispanic 29857 639
8 2008 Hispanic 28710 651
8 2009 Hispanic 28981 662
8 2010 Hispanic 28834 665
8 2011 Hispanic 28681 667
8 2006 White 10470 660
8 2007 White 9923 666
8 2008 White 9871 676
8 2009 White 9835 683
8 2010 White 9963 687
8 2011 White 9570 688
Step 10.php (Sort of)