Question: I am quite new to MySQL. I have data in more than 2000 text files that I need to import into a table. I have created the table as follow: 

```
CREATE TABLE test1
(   
    Month TINYINT UNSIGNED,
    Day TINYINT UNSIGNED,
    Year TINYINT UNSIGNED,
    Weight FLOAT UNSIGNED,
    length FLOAT UNSIGNED,
    Site_Number CHAR(3),
    id INT UNSIGNED NOT NULL AUTO_INCREMENT,
    PRIMARY KEY (id)
);

```

All data in my text files are comma separated. Each file contains thousands of rows and each row include month, day, year, weight and length information. The site\_number is the first three numbers of the file name. For example, if the file name is A308102316.txt, the site\_number of all the records imported from this file will be 308. Also, I want the ID to be auto increment. 

My question is: how can I achieve what I described above using MySQL command line client as I know nothing about PHP or other. I know how to import one text file into the table, but don't know how to write a loop to read many of them. Also, not know how to get site\_number from the file name.

Thank you for any help that you can provide.

Answer: 
The issue is that whether you find `null` or not the first pattern matches. After all, `t2: Seq[String]` could theoretically be `null`. While it's true that you can solve this immediately by simply making the `null` pattern appear first, I feel it is imperative to use the facilities in the Scala language to get rid of `null` altogether and avoid more bad runtime surprises.

So you could do something like this:

```
def foo(s: Seq[String]) = if (s.contains(null)) None else Some(s)
//or you could do fancy things with filter/filterNot

df.map {
   case (first, second) => (foo(first), foo(second))
}

```

This will provide you the `Some`/`None` tuples you seem to want, but I would see about flattening out those `None`s as well.
I think you will need to encode null values to blank or special String before performing assert operations. Also keep in mind that Spark executes lazily. So from the like "val values = df.flatMap" onward everything is executed only when show() is executed.