| | |
Interesting dilemma - See if you can help.
![]() |
•
•
Join Date: Nov 2009
Posts: 65
Reputation:
Solved Threads: 0
Hi,
I have stumbled on an interesting problem. I have thought 'n' thought, but haven't come up with any good ideas of how to handle this.
I have a text file that contains many records, but without the records being seperated. I need to figure out how to seperate these files, or at least how to write a program that recognizes different records and can then seperate them.
I don't expect anyone to write my program for me, but I need help seperating the records.
The beginning of every record looks like this: MSUBUGA JIMSON
P O BOX 21273
GABORONE
(Obviously they are all different, but always have 3 values on 3 lines.)
The end looks like this:
P107.17 P0.00 P225.08 P0.00 P332.25
(The numbers always vary, but there are always 5)
Any help will be greatly appreciated, Thank you.
I have stumbled on an interesting problem. I have thought 'n' thought, but haven't come up with any good ideas of how to handle this.
I have a text file that contains many records, but without the records being seperated. I need to figure out how to seperate these files, or at least how to write a program that recognizes different records and can then seperate them.
I don't expect anyone to write my program for me, but I need help seperating the records.
The beginning of every record looks like this: MSUBUGA JIMSON
P O BOX 21273
GABORONE
(Obviously they are all different, but always have 3 values on 3 lines.)
The end looks like this:
P107.17 P0.00 P225.08 P0.00 P332.25
(The numbers always vary, but there are always 5)
Any help will be greatly appreciated, Thank you.
0
#2 25 Days Ago
•
•
•
•
The beginning of every record looks like this: MSUBUGA JIMSON
P O BOX 21273
GABORONE
(Obviously they are all different, but always have 3 values on 3 lines.)
The end looks like this:
P107.17 P0.00 P225.08 P0.00 P332.25
(The numbers always vary, but there are always 5)
Can you give an small snippet of a file with at least two records for example? I envision either simply taking every 4 lines and parsing out the relevant info, or if there is a blank line between each record, just split at the blank lines.
If you read the file in with
readlines() , using index slicing you can easily grab groups of lines. ![]() |
Similar Threads
- News Story: Are celebrities killing Twitter? (Growing an Online Community)
- News Story: The Apple-Verizon Negotiation Yields Interesting Rumors (Mac Rumors and Reports)
- DVD ROM - Interesting problem (USB Devices and other Peripherals)
- Playing Old Apple Games on the PC: Yes, it's Possible (Posting Games)
- CD-RW problems (Storage)
- Search Engine Cloaking (Search Engine Optimization)
- Evolution: Science vs. Religion (Geeks' Lounge)
- Nice, Interesting Site (C++)
- Forum lurkers, introduce yourself ... !! (Community Introductions)
- java client server quiz. interesting!!! (Java)
Other Threads in the Python Forum
- Previous Thread: Limiting mouse movement
- Next Thread: Help with beginner question
| Thread Tools | Search this Thread |
address advanced aliased anydbm bash beginner bits calling casino changecolor clear conversion convert corners count csv cturtle cursor curves definedlines dictionary digital dynamic dynamically events examples excel external file float format frange function gui handling hints homework i/o iframe import input java line linux list lists loan loop matching mouse multiple number numbers output parsing path port prime programming projects py py2exe pygame python random rational raw_input recursion recursive scrolledtext searchingfile shebang signal singleton string strings subprocess table tails terminal text thread threading time tkinter tlapse tooltip tuple tutorial type ubuntu unicode urllib urllib2 valueerror variable web-scrape whileloop word wxpython






