On 5/17/07, Robert Rawlins - Think Blue <[EMAIL PROTECTED]>
wrote:

 Hello Guys,



I'm currently working on a non-python project, and I'm trying to overcome
a task of parsing a text file into a database and/or xml file. I've managed
to find a parser example written in python, and I'm hoping to deconstruct
the code methodology a bit so I can write it in another language. So I'm
hoping someone can explain to me what these following bits of code are
doing.



lines = range(data.count("\n"))

lined_data = data.split("\n")


eg:
data="abc\n123\ngh\nxyz\n"
data.split("\n") will give you an array(list in python) in the following
manner
['abc', '123', 'gh', 'xyz']


print "Read %i vendors, now processing" % data.count("(hex)")



I've not used the split() function before, but it partly makes sense to
me. What is that piece of code doing? 'Data' is the content of the text
file, presumably the first line there is counting the number of lines in the
file, but I don't get the rest of it.



The rest of the code seems like a relatively simple set of loops, but it's
just this splitting stuff that's got me confused.



Thanks,



Rob

--
http://mail.python.org/mailman/listinfo/python-list




--
Regards--
Rishi Pathak
National PARAM Supercomputing Facility
Center for Development of Advanced Computing(C-DAC)
Pune University Campus,Ganesh Khind Road
Pune-Maharastra
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to