dbTalk Databases Forums  

Re: Import/Convert Text File - Help!

comp.databases comp.databases


Discuss Re: Import/Convert Text File - Help! in the comp.databases forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Bob Badour
 
Posts: n/a

Default Re: Import/Convert Text File - Help! - 07-10-2003 , 11:36 AM






"Scoop" <Scoop-no-spam (AT) antigone (DOT) cotse.net> wrote

Quote:
I have a text file that is a mess. Apparently, the data is taken from
some
type of form that puts the information in a plain text file as follows:

****************************
NAME:

ADDRESS:

TELEPHONE:

DATE OF BIRTH:

BRITTANY SPEARS

1212 FAKECHEST WAY

BOULDER, CO 22119

(202)234-5678

3/12/03

****************************

You can see that the NAME: is BRITTANY SPEARS but the information is
separated by several lines. What I am trying to do is convert the above
text file to look as follows:

BRITTANY SPEARS, 1212 FAKECHEST WAY, BOULDER, CO, 22119, (202)234-5679,
3/12/03

With a carriage return separating each record. Basically, I want to scan
the entire text file and put the data in some order that is more "usable."
Any and all help appreciated.
From your description, I don't see what the problem is. Just write a program
to read in the file and write out a new file in the format you want. Any
programming language will do while perl or awk jump out at me as strongish
candidates.




Reply With Quote
  #2  
Old   
Christopher Browne
 
Posts: n/a

Default Re: Import/Convert Text File - Help! - 07-10-2003 , 10:20 PM






After a long battle with technology,"Scoop" <Scoop-no-spam (AT) antigone (DOT) cotse.net>, an earthling, wrote:
Quote:
I have a text file that is a mess. Apparently, the data is taken from some
type of form that puts the information in a plain text file as follows:

****************************
NAME:

ADDRESS:

TELEPHONE:

DATE OF BIRTH:

BRITTANY SPEARS

1212 FAKECHEST WAY

BOULDER, CO 22119

(202)234-5678

3/12/03

****************************

You can see that the NAME: is BRITTANY SPEARS but the information is
separated by several lines. What I am trying to do is convert the above
text file to look as follows:

BRITTANY SPEARS, 1212 FAKECHEST WAY, BOULDER, CO, 22119, (202)234-5679, 3/12/03

With a carriage return separating each record. Basically, I want to scan
the entire text file and put the data in some order that is more "usable."
Any and all help appreciated.
I have used numerous languages for this purpose, including Perl,
Python, Scheme, and Common Lisp. Icon would doubtless also do a good
job of it. And Ruby, awk, and others would also work.

This is a typical "database conversion" sort of problem; what you have
to do is to pick a text processing language and come up with a
strategy for parsing the bits that are fiddly.

There's no generic answer because every such "input format" has its
own unique characteristics.

No self-respecting awk/Perl programmer would have any trouble with
it...
--
"aa454","@","freenet.carleton.ca"
http://www.ntlug.org/~cbbrowne/unix.html
Marriage means commitment. Of course, so does insanity.


Reply With Quote
  #3  
Old   
Ed Guy
 
Posts: n/a

Default Re: Import/Convert Text File - Help! - 07-11-2003 , 01:49 AM



Scoop wrote:

Quote:
I have a text file that is a mess. Apparently, the data is taken from some
type of form that puts the information in a plain text file as follows:

****************************
NAME:

ADDRESS:

TELEPHONE:

DATE OF BIRTH:

BRITTANY SPEARS

1212 FAKECHEST WAY

BOULDER, CO 22119

(202)234-5678

3/12/03

****************************

You can see that the NAME: is BRITTANY SPEARS but the information is
separated by several lines. What I am trying to do is convert the above
text file to look as follows:

BRITTANY SPEARS, 1212 FAKECHEST WAY, BOULDER, CO, 22119, (202)234-5679, 3/12/03

With a carriage return separating each record. Basically, I want to scan
the entire text file and put the data in some order that is more "usable."
Any and all help appreciated.
Take a look at ParseRat (http://www.parserat.com) - treat each block as a "page
image" on input.


--
Ed Guy P.Eng,CDP,MIEE
Information Technology Consultant
Internet: ed (AT) guysoftware (DOT) com
http://www.guysoftware.com
"Check out HELLLP!, WinHelp author tool for WinWord 2.0 through 8.0,
PlanBee Project Management Planning System
and ParseRat, the File Parser, Converter and Reorganizer"




Reply With Quote
  #4  
Old   
Ed Prochak
 
Posts: n/a

Default Re: Import/Convert Text File - Help! - 07-18-2003 , 07:18 PM



Scoop wrote:
Quote:
I have a text file that is a mess. Apparently, the data is taken from some
type of form that puts the information in a plain text file as follows:

****************************
NAME:

ADDRESS:

TELEPHONE:

DATE OF BIRTH:

BRITTANY SPEARS

1212 FAKECHEST WAY

BOULDER, CO 22119

(202)234-5678

3/12/03

****************************

You can see that the NAME: is BRITTANY SPEARS but the information is
separated by several lines. What I am trying to do is convert the above
text file to look as follows:

BRITTANY SPEARS, 1212 FAKECHEST WAY, BOULDER, CO, 22119, (202)234-5679, 3/12/03

With a carriage return separating each record. Basically, I want to scan
the entire text file and put the data in some order that is more "usable."
Any and all help appreciated.






You'll be best off using a test processing language like PERL. But even with
that you are going to have lot's of fun programming the exceptions!

contact me if you want a little more detail. I've done lots of data
conversions with PERL. Or go to the comp.lang.perl group.

--
Ed Prochak
running http://www.faqs.org/faqs/running-faq/
netiquette http://www.psg.com/emily.html
--
"Two roads diverged in a wood and I
I took the one less travelled by
and that has made all the difference."
robert frost



Reply With Quote
  #5  
Old   
Otto Hundt
 
Posts: n/a

Default Re: Import/Convert Text File - Help! - 07-25-2003 , 03:57 AM



If I have to do such things, I first use my programming editor
(slickedit.com) to make some first clean ups "by hand". This works really
fine using macros and regular expressions. Within a few minutes I can
create nearly any data structures I want.

Otto


Ed Prochak <edprochak (AT) adelphia (DOT) net> wrote in
news:3F1892BE.2040304 (AT) adelphia (DOT) net:

Quote:
Scoop wrote:
I have a text file that is a mess....


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.