Python/Python for Windows

[Python] pandas를 이용한 iis-ftp log 파싱

Pydole 2019. 9. 16. 21:09

python pandas를 이용한 iis-ftp log 파싱

 

#Fields: date time c-ip c-port cs-username s-sitename s-computername cs-host s-ip s-port cs-method

              cs-uri-stem sc-status sc-win32-status sc-substatus sc-bytes cs-bytes time-taken x-session x-fullpath

              x-debug

 

import pandas as pd

log_field = ['date', 'time', 'c-ip', 'c-port' , 'cs-username', 's-sitename', 's-computername', 'cs-host',
             's-ip', 's-port', 'cs-method' ,'cs-uri-stem' ,'sc-status', 'sc-win32-status', 'sc-substatus',
             'sc-bytes', 'cs-bytes', 'time-taken', 'x-session', 'x-fullpath', 'x-debug']

df = pd.read_csv(filename, sep=' ', comment='#', engine='python', names=log_field)
print(df)
--------------------------------------------------------------------------------------------

...            ...  ...                                  ...
104519  2019-09-09  ...                                    -
104520  2019-09-09  ...                                    -
104521  2019-09-09  ...                                    -
104522  2019-09-09  ...                                    -
104523  2019-09-09  ...                                    -

[104524 rows x 21 columns]