Thanks for the response, I needed to maintain the text file in its format and managed to achieve this and a count of lines with:

[code]
array = []

file = open('filename.txt')
for line in file.readlines():
line = line.split(',')
array.append(line)

i = len(line)

file.close()
[/code]

Hi python fans, hope someone can help me with this.

I have a text file the result of another program which looks like:

2,6,3,5,0
4,0,2,5,2
5,7,9,1,0
4,6,8,2,5
2,7,9,1,6

This may vary in size but will always be square i.e. 5x5, 9x9 etc so the code needs to accomodate this, the maximum ever size will probably be 12x12.

I want python code which will read in the text file and store it in a way I may then access each individual number.

Thanks in advance, assistance appreciated in the meantime I'm off to try and crack it and if I find out first then I'll post back.

Apologies if I have confused the situation and also for the code displaying as it is I did insert the tags but clearly did something wrong.

Your advice on the stylesheet has worked perfectly, the only advice I now would be grateful for is generating the index.html which just contains links to each page, I can then work on design at a later date.

Lastly, some direction on how you then reference another xml file to extract details during page creation would be much appreciated. These will be my products as the example of code above.

Many thanks for the response I'm currently working through the code to make sense of it all as I like to understand what it's doing, although good news is I have literally been able to copy the stylesheet code you have provided and immediately generate the html pages I require.

What I have yet to understand is what is the purpose of the code setting the table properties (i.e. border size etc) no tables are displayed in the html pages?

Also the index.html page is not automatically generated with links to each page, should it be? Once I have that I'm quietly confident of working on improving the quality of the page.

Lastly, I need to pull the products I am selling from my products.xml file (short example below) do I do this within the </xsl:result-document> section?

Thanks in advance, a friend advised I use XML for my website and I see the benefits long term but I have a lot to learn still I guess!

[CODE][/CODE]
<?xml version = "1.0" encoding = "UTF-8"?>

<catalog>
<product>
<productid>0001</productid>
<title>Product 1</title>
<price>2.99</price>
<image>prod1.jpg</image>
<imagelarge>prod1x.jpg</imagelarge>
<desc>A description of product 1.</desc>
<features>Prod1 feature</features>
<features>Prod1 another feature</features>
<stock>In Stock</stock>
<include>
<category>This Category</category>
<subcategory>This Subcategory 1</subcategory>
</include>
<include>
<category>This Category</category>
<subcategory>This Subcategory 4</subcategory>
</include>
</product>
<product>
<productid>0002</productid>
<title>Product 2</title>
<price>1.99</price>
<image>prod2.jpg</image>
<imagelarge>prod2x.jpg</imagelarge>
<desc>A description of product 2.</desc>
<features>Prod2 only one feature</features>
<stock>Out of Stock</stock>
<include>
<category>That Category</category>
<subcategory>That Subcategory 3</subcategory>
</include>
</product>
</catalog>
[CODE][/CODE]

I have successfully produced schemas, hooray! Basically a product:

Must have a ...

Hi

Please help this is driving me insane, I've simplified my XML and stylesheet below for explaining what I'm trying to achieve.

My stylesheet is successfully generating a HTML file for each of my categories using title i.e.

This Category.html
That Category.html

It also generates a simple index.html at the end which contains links to each of these pages.. However what I also want to achieve is:

This Category - This Sub Category 1.html
This Category - This Sub Category 2.html
This Category - This Sub Category 3.html
That Category - That Sub Category 1.html
That Category - That Sub Category 2.html
That Category - That Sub Category 3.html

With an index page that references each page, once I have this in place I can really start my website for my shop. I'm assuming I need another for-each loop

within the category for-each loop but when I do this I only get the 'This Category.html' level files generated. Whereas if I remove the inner for-each loop

I also get:

'This Sub Category 1 This Sub Category 2 This Sub Category 3.html' etc

Not what I want but hopefully I'm already close.

Hope this makes sense and thanks in advance.

XML:

<?xml version = "1.0" encoding = "UTF-8"?>
<categories>
    <category>
        <title>This Category</title>
        <subcategory>This Sub Category 1</subcategory>
        <subcategory>This Sub Category 2</subcategory>
        <subcategory>This Sub Category 3</subcategory>
    </category>
    <category>
        <title>That Category</title>
        <subcategory>That Sub Category 1</subcategory>
        <subcategory>That Sub Category 2</subcategory>
        <subcategory>That Sub Category 3</subcategory>
    </category>
</categories>

XSLT:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet 
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
  version="2.0">

<xsl:output method="text"/> ...