| | |
Interesting dilemma - See if you can help.
Please support our Python advertiser: Programming Forums - DaniWeb Sister Site
![]() |
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 Nov 5th, 2009
•
•
•
•
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? (Social Media and Online Communities)
- 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 |
Tag cloud for Python
accessdenied apache application argv beginner book change code color converter dictionary dynamic edit editing enter examples excel file filename float format ftp function gui homework import inches input java keyboard lapse library line lines linux list lists loop microphone mouse movingimageswithpygame mysql newb number numbers numeric output parameters parsing path phonebook port prime program programming projects py2exe pygame pyopengl pyqt python random recursion recursive redirect remote reverse scrolledtext server session simple smtp software sprite ssh statictext string strings syntax table tennis terminal text thread threading time tkinter tlapse trick tuple tutorial ubuntu unicode unit urllib urllib2 variable windows wordgame wxpython






