Read from Regex Function
I'm working on a project involving log file analysis and wrote a method which takes a regex, a file name and list of column names, parses the data and returns a pandas DataFrame.

I haven't extensively tested this yet, but the code below successfully reads in an apache log file using the regex below and returns a DataFrame with all the data in the correct columns.  Would anyone else find this useful and if so, what would I need to do to contribute this to the code base?
Thanks,

``` python
""" io from regex """
from pandas import DataFrame
import re

def read_from_regex(**kwargs):
    """
    Read text from an input file, apply a regex to it and store data into a DataFrame
    Returns
    -------
    parsed : DataFrame
    """
    pattern = kwargs.get('r')
    columns = kwargs.get('columns')

    inputFile = open(kwargs.get('input'), 'r')

    table = []
    for line in inputFile:
        matchObj = re.search(pattern, line)
        if matchObj:
            row = {}
            fieldCount = len(matchObj.groups())
            if len(columns) > 0:
                for i in range(1, fieldCount):
                    row[columns[i]] = matchObj.group(i)    
            else:
                for i in range(1, fieldCount):
                    row[i] = matchObj.group(i)

            table.append(row)

    return DataFrame(table)


def main():
    pattern = r'(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})\s(\S+)\s(\S+)\s\[(\d{2}/\w+?/\d{4}:\d{2}:\d{2}:\d{2}\s-\d{4})\]\s"([A-Z]+)\s(\S+?)\s(\S+)"\s(\d{3})\s(\S+?)\s"(\S+?)"\s"(.+?)"'

    columnNames = ['ipAddress', 'remoteLogname', 'username', 'dateTime', 'request', 'requestLine' , '', 'responseCode', 'bytesSent', 'referrer', 'userAgent' ]


    data = read_from_regex( r=pattern, input='apache-logs.txt', columns=columnNames )
    print( data.describe() )

if __name__ == "__main__":main() ## with if

```
