Saeed Azarshab
Saeed Azarshab

Reputation: 31

multiple columns from single column in python

I am trying to split a column into multiple columns

The column has values like this:

 message
 ------------
 time=15:45:19 devname="FG3H0E3917903319" devid="FG3H0E3917903319" 
 logid="1059028705" type="utm" subtype="app-ctrl" eventtype="app-ctrl-all" 
level="warning" vd="root" eventtime=1564226119 appid=16009 
srcip=172.24.208.2 dstip=93.184.221.240 srcport=4832 dstport=80 
srcintf="LAN-RahaNet" srcintfrole="lan" dstintf="WAN-RahaNet" 
dstintfrole="lan" proto=6 service="HTTP" direction="outgoing" policyid=43 
 sessionid=493024483 applist="LanAppControl" appcat="Update" 
app="MS.Windows.Update" action="block" 
hostname="www.download.windowsupdate.com" incidentserialno=1522726002 
url="/msdownload/update/v3/static/trustedr/en/authrootseq.txt" msg="Update: 
MS.Windows.Update," apprisk="elevated"

Basically I need to split this column into:

time         devname                devid           ...
--------------------------------------------------------------
15:45:19    FG3H0E3917903319     FG3H0E3917903319     ...

Upvotes: 1

Views: 55

Answers (1)

Anuvrat Parashar
Anuvrat Parashar

Reputation: 3110

short answer:

  1. split the message on space, to get a list of key value pairs.
  2. split every key-value pair on = sign.
  3. add corresponding keys to their respective columns.

Upvotes: 1

Related Questions