Question: I've looked at several [similar](http://www.intstrings.com/ramivemula/articles/data-transfer-between-two-asp-net-pages/) [questions](https://stackoverflow.com/questions/9640286/pass-data-into-user-control-on-master-page-from-sub-page) to this one and right now I am trying to use the FindControl method without success.

My Web Forms application has several master pages. Common to all master pages is a search box and button in a nav user control at the top. I'm trying to grab the search term entered on the SearchResults page:

```
HtmlGenericControl topNavDiv = (HtmlGenericControl)Master.FindControl("topNavDiv");
Control topNav = (UserControl)Page.FindControl("topNav");
if (topNav != null)
{
    TextBox searchBox = topNav.FindControl("searchBox") as TextBox;
    if (searchBox != null)
    {
        Response.Write(searchBox.Text.Trim());
    }
    else
    {
        resultsPanel.Visible = false;
        messagePanel.Visible = true;
     }
}

```

In the first line, the topNavDiv variable is null. I was considering accessing the user control via a master page property, but **with several different master pages I don't know how to determine the id of the master page as the search could be initiated from anywhere in the site...**

**UPDATE:**

I was able to grab the topNav div, searchBox textbox as follows:

```
Control topNav = (UserControl)Master.FindControl("topNav");
if (topNav != null)
{
    TextBox searchBox = topNav.FindControl("searchBox") as TextBox;
    if (!String.IsNullOrEmpty(searchBox.Text))
    {
        Response.Write(searchBox.Text.Trim());
    }
    else
    {
        resultsPanel.Visible = false;
        messagePanel.Visible = true;
    }
}

```

The only problem is that the search box text entered is not being persisted.

Answer: 
You can do:

```
DataCaptured = csv.reader(DataFile, delimiter=',', skipinitialspace=True) 

Category, Year = [], []
for row in DataCaptured:
    if row[0] not in Year:
        Year.append(row[0])
    if row[1] not in Category:
        Category.append(row[1])    

print Category, Year        
# ['Category1', 'Category2', 'Category3'] ['1994', '1995', '1996', '1998']

```

---

As stated in the comments, if order does not matter, using a set would be easier and faster:

```
Category, Year = set(), set()
for row in DataCaptured:
    Year.add(row[0])
    Category.add(row[1])

```
A very concise way to do this is to use `pandas`, the benefits are: it has a faster CSV pharser; and it works in columns (so it only requires one `df.apply(set)` to get you there) :

```
In [244]:
#Suppose the CSV is named temp.csv
df=pd.read_csv('temp.csv',header=None)
df.apply(set)
Out[244]:
0                        set([1994, 1995, 1996, 1998])
1            set([ Category2,  Category3,  Category1])
2    set([ Something Happened 4,  Something Happene...
dtype: object

```

The downside is that it returns a `pandas.Series`, and to get access each list, you need to do something like `list(df.apply(set)[0])`.

Edit
====

If the order has to be preserved, it can be also done very easily, for example:

```
for i, item in df.iteritems():
    print item.unique()

```

`item.unique()` will return `numpy.array`s, instead of `list`s.