Feb-15-2017, 04:43 AM
Great coders, I am having this problem and unable to solve from similar threads.
I have no idea how to do this - seems importing the csv module is a good starting point.
Problem is that the data is not "linear".
The word(s) to the left of the colon is the field name (header) and to the right the data.
The input file is rather large.
I don't expect you to code this for me, but a little guidance to solve this problem would be greatly appreciated.
My python is rather old (2.6.8).
This is the output file that have to be parsed:
I have no idea how to do this - seems importing the csv module is a good starting point.
Problem is that the data is not "linear".
The word(s) to the left of the colon is the field name (header) and to the right the data.
The input file is rather large.
I don't expect you to code this for me, but a little guidance to solve this problem would be greatly appreciated.
My python is rather old (2.6.8).
This is the output file that have to be parsed:
Output:####################################
LOCATION: home ----> This I need
####################################
some non-interesting text to be discarded.
================================================================================
item table (details)
================================================================================
--------------------------------------------------------------------------------
item
--------------------------------------------------------------------------------
color : silver type : fridge
mandatory : yes substance : metal
viscosity : solid
winter use : always
chemicals : refrigerant
safe for kids : yes
accessories : cooler
cleaning : cloth
================================================================================
####################################
LOCATION: home ----> This I need
####################################
some non-interesting text to be discarded.
================================================================================
item table (details)
================================================================================
--------------------------------------------------------------------------------
item
--------------------------------------------------------------------------------
color : blue type : pool
mandatory : no substance : water
viscosity : liquid
winter use : never
chemicals : chlorine
safe for kids : depends
accessories : pump
cleaning : filter
I expect a simliar output of:Output:LOCATION, color, type, mandatory, substance, viscosity,winter use, chemicals, safe for kids, accessories, cleaning
home, silver, fridge, yes, metal, solid, always, refrigerant, yes, cooler, cloth
home, blue, pool, no, water, liquid, never, chlorine, depends, pump, filter