Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

Python parsing

Name: Anonymous 2009-07-17 12:36

I've been trying to grasp this for hours and it's embarassing, but I can't figure it out.

I'm dealing with raw files that are created as one huge line, but there are 3 character combos that show where each line should have began.

So I'm trying to read the file in and write one out that's properly formatted.  I've been thinking about how to do it in python and perl and I have no fucking clue.

Help, /prog/?

Name: Anonymous 2009-07-17 12:38

but there are 3 character combos that show where each line should have began
Can you re-phrase that?  There are 3 different characters, and anywhere one appears is the beginning of a new line?

Name: Anonymous 2009-07-17 12:46

Sorry, that was vague.  There are certain combinations of characters (e.g. OBX, OBR) that should begin a new line.

So, it should be like this:

OBX(text)
OBX(text)
OBR(text)

But is instead like this:

OBX(text)OBX(text)OBR(text)...

Name: Anonymous 2009-07-17 12:53

sed -re 's/(OBX|OBR)/\n/g'

Wat.

Name: Anonymous 2009-07-17 12:55

>>4
DON'T HELP HIM!

Name: Anonymous 2009-07-17 13:12

Well, from looking up the syntax of sed, I found out about str.replace() in python.

Thanks, anon.

Name: Anonymous 2009-07-17 13:14

>>5
Motherfucking son of a whore.

Name: Anonymous 2009-07-17 13:28

rawtext.replace(')',')\n')

Don't change these.
Name: Email:
Entire Thread Thread List