Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Log process
#1
Hello,

I have a log that looks something like like this:
Field1=Value1, Field=Value2, Field3=Value3, Field4=Value4
Field1a=Value1a, Field2a=Value2a, Field3a=Value3a, Filed4a=Value4a


The goal is get this output

Value1 Value2 Value3 Value4
Value1a Value2a Value3a Value4a

I can do this in a a perl one-liner by getting everything into an array splitting by comma.
Then modifying the array and further splitting by equal sign.

What is the easiest and quickest way to accomplish this in python?

Thanks
Reply
#2
(Aug-08-2017, 03:31 AM)besogon Wrote: I can do this in a a perl one-liner by getting everything into an array splitting by comma. Then modifying the array and further splitting by equal sign. What is the easiest and quickest way to accomplish this in python?

It is more or less the same - read the file line by line, split at commas, split at equal sign... you can use list comprehension or do it as a nested loop for example
Please, post your code if you need further assistance
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  How to sharing object between multiple process from main process using Pipe Subrata 1 3,617 Sep-03-2019, 09:49 PM
Last Post: woooee

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020