Python Forum
It looks like an error but maybe not
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
It looks like an error but maybe not
#1
Hi,
I'm splitting lines and having this message:
['<SupplementalData', 'Name', 'Placeholder', 'Value', 'Placeholder', '/>\n']

What does it mean?

Thank you.
Reply
#2
This is list of strings. That is what str.split() method will return.
If you need more help, post your code in python tags, as well as sample input and expected output.
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#3
Sure.
I'm trying to pull out two lines after a matched line, I'm splitting both lines and will extract elements from each line and print it it to a different file.
I have no errors after the first:
ln_f = next (each_dirf)
but after the second:
ln_f = next (each_dirf)
errors starts.

Here is a bloc I have the problem with.
I have next two bloks like this one and both producing the same error. rest of the "IF" blocks having NO problems.

                    if 'type="HDDD' in ln_f :                                                            
                        ln_f = next (each_dirf)
                        
                        ln_f = ln_f.lstrip()
                        ln_f = ln_f.replace("=", " ").replace('"','')
                        mm11 = ln_f.split(" ")                         
                        w1 = slot_number+","+mm11[8]+","+mm11[10]+","+mm11[12]+","+mm11[14]+","+mm11[18]+" "+mm11[19]
                        
                        XML_Lines_Out.write(w+w1+'\n')

                        ln_f = next (each_dirf)                                         
                        ln_f = ln_f.lstrip()
                        print (">>>>> ", ln_f)  
Reply
#4
we don't know what you work with, i.e. what your input is.
please post, minimal, reproducible example that demonstrate the problem as well as sample input.
Also, note - if you work with xml file, as suggested by XML_lines_Out, I don't think parsing it like simple text line with str.split, etc is good idea, use appropriate tools for working with xml file.
you speak of errors, but so far we haven't seen any errors, just some output from str.split().
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#5
I'm scannig about 300-500 files and I just found 2 (two) file are non standard and that is why the code has a problem printing correct lines. Thank you fro trying to help me. I really appriciate it! You guys are awesome!

Thank you again!
Reply


Forum Jump:

User Panel Messages

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