python - Regular Expression to extract CSV data, some fields are quoted and contain commas -


i have following types of input data (for splunk)

svr28pr,linux file system-all,success,32.87,2638.259,26/06/14 19:00,26/06/14 21:03,avamar xxxxx1.network.local,activity completed exceptions.,26/06/14 19:00 svr44pr:staging_syncdb,incr,success,1271,1271,27/06/14 11:28,27/06/14 11:28,sql,,,1/01/70 09:59 

i need break out fields - following expression worked well.

(?<client>[^,]+),(?<backuptype>[^,]+),(?<status>[^,]+),(?<size>[^,]+),(?<dump>[^,]+),(?<start>[^,]+),(?<complete>[^,]+),(?<application>[^,]+),(?<server>[^,]+),(?<comment>[^,]+) 

however, due change in names of backuptypes, second field may quoted , contain commas e.g.

svr08ts,"windows vss-all,all",success,0.067,39.627,26/06/14 21:32,26/06/14 21:38,avamar,xxxxxxx2.network.local,activity completed exceptions.,26/06/14 20:00 

is there way using regex determine whether field uses quotes , if copy data between quotes named group?

you can use multikv in splunk process tabular data.


Comments

Popular posts from this blog

Unable to open serial port using Putty to bluetooth device on windows 7 64 bit -

bash - How do you programmatically add a bats test? -

java - Getting exception in JDBC thin driver -