<commit_before>using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Xml;
using System.Linq;

public class Spreadsheet : IOpenDocument
{
    private string Name = "test";
    private List<List<Cell>> rows;

    public string Mimetype
    {
        get
        {
            return "application/vnd.oasis.opendocument.spreadsheet";
        }
    }
    public string Body
    {
        get
        {
            var contents = new StringBuilder();
            var writer = new StringWriter(contents);

            var xml = new XmlTextWriter(writer);
            xml.Formatting = Formatting.Indented;

            xml.WriteStartElement("office:spreadsheet");

            WriteTable(xml);

            xml.WriteEndElement();  // </office:spreadsheet>

            return contents.ToString();
        }
    }

    public string Style
    {
        get
        {
            return "";
        }
    }

    public Spreadsheet()
    {
        rows = new List<List<Cell>>();
    }

    public void SetCell(string a1, string value)
    {
        var cell = new Cell(a1, value);
        int x = cell.Column;
        int y = cell.Row;
        while (y >= rows.Count)
        {
            rows.Add(new List<Cell>());
        }

        var row = rows[y];
        while (x >= row.Count)
        {
            row.Add(null);
        }

        row[x] = cell;
    }

    private void WriteTable(XmlWriter xml)
    {
        xml.WriteStartElement("table:table");
        xml.WriteAttributeString("table:name", Name);

        xml.WriteElementString("table:table-column", null);
        foreach (var row in rows)
        {
            xml.WriteStartElement("table:table-row");
            foreach (var cell in row)
            {
                if (cell != null)
                    cell.Write(xml);
                else
                    xml.WriteElementString("table:table-cell", null);
            }
            xml.WriteEndElement();  // </table:table-row>
        }
        xml.WriteEndElement();  // </table:table>
    }
}

class Cell
{
    private string value;
    public int Column { get; private set; }
    public int Row { get; private set; }

    public Cell(int column, int row)
    {
        Column = column;
        Row = row;
    }

    public Cell(string a1)
    {
        string numbers = new string(a1.SkipWhile(
                                l => char.IsLetter(l)).ToArray());
        string letters = new string(a1.TakeWhile(
                                l => char.IsLetter(l)).ToArray());

        Row = int.Parse(numbers) - 1;
        Column = 0;
        if (letters != null && letters.Length > 0)
        {
            Column = letters[0] - 'A';
            for (int i = 1; i < letters.Length; i++)
            {
                Column *= 26;<commit_msg>Add ability to GetCell's from sheet<commit_after>using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Xml;
using System.Linq;

public class Spreadsheet : IOpenDocument
{
    private string Name = "test";
    private List<List<Cell>> rows;

    public string Mimetype
    {
        get
        {
            return "application/vnd.oasis.opendocument.spreadsheet";
        }
    }
    public string Body
    {
        get
        {
            var contents = new StringBuilder();
            var writer = new StringWriter(contents);

            var xml = new XmlTextWriter(writer);
            xml.Formatting = Formatting.Indented;

            xml.WriteStartElement("office:spreadsheet");

            WriteTable(xml);

            xml.WriteEndElement();  // </office:spreadsheet>

            return contents.ToString();
        }
    }

    public string Style
    {
        get
        {
            return "";
        }
    }

    public Spreadsheet()
    {
        rows = new List<List<Cell>>();
    }

    public void SetCell(string a1, string value)
    {
        var cell = new Cell(a1, value);
        int x = cell.Column;
        int y = cell.Row;
        while (y >= rows.Count)
        {
            rows.Add(new List<Cell>());
        }

        var row = rows[y];
        while (x >= row.Count)
        {
            row.Add(null);
        }

        row[x] = cell;
    }

    public Cell GetCell(string a1)
    {
        var cell = new Cell(a1);
        var x = cell.Column;
        var y = cell.Row;

        if (y < rows.Count)
            if (x < rows[y].Count)
                return rows[y][x];
        return null;
    }

    private void WriteTable(XmlWriter xml)
    {
        xml.WriteStartElement("table:table");
        xml.WriteAttributeString("table:name", Name);

        xml.WriteElementString("table:table-column", null);
        foreach (var row in rows)
        {
            xml.WriteStartElement("table:table-row");
            foreach (var cell in row)
            {
                if (cell != null)
                    cell.Write(xml);
                else
                    xml.WriteElementString("table:table-cell", null);
            }
            xml.WriteEndElement();  // </table:table-row>
        }
        xml.WriteEndElement();  // </table:table>
    }
}

public class Cell
{
    private string value;
    public int Column { get; private set; }
    public int Row { get; private set; }

    public Cell(int column, int row)
    {
        Column = column;
        Row = row;
    }

    public Cell(string a1)
    {
        string numbers = new string(a1.SkipWhile(
                                l => char.IsLetter(l)).ToArray());
        string letters = new string(a1.TakeWhile(
                                l => char.IsLetter(l)).ToArray());

        Row = int.Parse(numbers) - 1;
        Column = 0;
        if (letters != null && letters.Length > 0)
        {
            Column = letters[0] - 'A';
            for (int i = 1; i < letters.Length; i++)
            {
                Column *= 26;
{'fraction_non_alphanumeric': 0.11435853865760408, 'fraction_numerical': 0.004418011894647409, 'mean_word_length': 1.4793597304128054, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 29, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 28}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '612784', 'n_tokens_mistral': 1715, 'n_tokens_neox': 1627, 'n_words': 401}