Importing data from a text document

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Importing data from a text document

Carl Aage Wangel
I wonder if somebody could point me in the right direction

I am to import data to 4D from a plain text document (WordPad) that look
something like this:

%

DOname;1;20060612;235917; ;

MI13.8;13.8;;;;

ED9;0;31198;30;2;0;;45632;;0;1;

ED10;0;55340;20;2;0;;58512;;0;4;

ED37;0;24258;1;1;0;;1058;;0;5;

ED38;0;25495;1;1;0;;1146;;0;12;

ED39;0;23023;2;1;0;;1012;;0;0;

ED40;0;23759;2;1;0;;1146;;0;7;

ED41;0;24481;2;1;0;;1146;;0;7;

ED42;0;24011;2;1;0;;1146;;0;4;

ED43;0;24078;2;1;0;;1186;;0;8;

ED44;0;24461;2;1;0;;1344;;0;8;

#

The document always start with % and ends with #.

The second line always starts with DO.

The third line always starts with MI.

The followings lines always start with ED.

I imagine I need 3 tables, one for the DO-data, one for the MI-data and one
for the ED-data. What would be the best way to programmatically catch the
appropriate data to the various tables? And how would I export a similar
document?

 

Carl Aage Wangel

**********************************************************************
Learn by example. Download free 4D 2004 example applications today!
http://www.4d.com/2004/examples.html

4th Dimension Internet Users Group (4D iNUG)
FAQ:  <http://www.4d.com/support/faqnug.html>
Archive:  <http://dir.gmane.org/gmane.comp.lang.inug-4d.tech>
Unsub:  mailto:  [hidden email]
**********************************************************************

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

RE: Importing data from a text document

Garri Ogata
Hi Carl,

I would suggest open document/create document and recieve packet/send packet
for importing/exporting respectively.

I'm not sure why you need three tables.  You may find it can all be done in
one file.  Will you import multiple documents at one time?  Will they need
to be identified as such?  Can data from one document be mixed with data
from another?

Garri

>From: "Carl Aage Wangel" <[hidden email]>
>Reply-To: "4D iNUG Technical" <[hidden email]>
>To: <[hidden email]>
>Subject: Importing data from a text document
>Date: Wed, 12 Jul 2006 20:36:53 +0200
>
>I wonder if somebody could point me in the right direction
>
>I am to import data to 4D from a plain text document (WordPad) that look
>something like this:
>
>%
>
>DOname;1;20060612;235917; ;
>
>MI13.8;13.8;;;;
>
>ED9;0;31198;30;2;0;;45632;;0;1;
>
>ED10;0;55340;20;2;0;;58512;;0;4;
>
>ED37;0;24258;1;1;0;;1058;;0;5;
>
>ED38;0;25495;1;1;0;;1146;;0;12;
>
>ED39;0;23023;2;1;0;;1012;;0;0;
>
>ED40;0;23759;2;1;0;;1146;;0;7;
>
>ED41;0;24481;2;1;0;;1146;;0;7;
>
>ED42;0;24011;2;1;0;;1146;;0;4;
>
>ED43;0;24078;2;1;0;;1186;;0;8;
>
>ED44;0;24461;2;1;0;;1344;;0;8;
>
>#
>
>The document always start with % and ends with #.
>
>The second line always starts with DO.
>
>The third line always starts with MI.
>
>The followings lines always start with ED.
>
>I imagine I need 3 tables, one for the DO-data, one for the MI-data and one
>for the ED-data. What would be the best way to programmatically catch the
>appropriate data to the various tables? And how would I export a similar
>document?
>
>
>
>Carl Aage Wangel
>
>**********************************************************************
>Learn by example. Download free 4D 2004 example applications today!
>http://www.4d.com/2004/examples.html
>
>4th Dimension Internet Users Group (4D iNUG)
>FAQ:  <http://www.4d.com/support/faqnug.html>
>Archive:  <http://dir.gmane.org/gmane.comp.lang.inug-4d.tech>
>Unsub:  mailto:  [hidden email]
>**********************************************************************
>


**********************************************************************
Learn by example. Download free 4D 2004 example applications today!
http://www.4d.com/2004/examples.html

4th Dimension Internet Users Group (4D iNUG)
FAQ:  <http://www.4d.com/support/faqnug.html>
Archive:  <http://dir.gmane.org/gmane.comp.lang.inug-4d.tech>
Unsub:  mailto:  [hidden email]
**********************************************************************

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Importing data from a text document

Chip Scheide
In reply to this post by Carl Aage Wangel

pseudo code


read line (or block of text or entire file)

repeat
 
 for each line of text
  create record
  locate ";" in text
  $Found:=text between start of text and ";"
  assign $Found to a field in new record (convert data type as needed)
  remove $Found from text
 end for
until no more data to import (end of text)


if you look here:
<www.homepage.mac.com/dromidary>

find the 4D code folder, there is code there for parsing text (like
below) into the individual elements for use in importing.

its free

On Wed, 12 Jul 2006 20:36:53 +0200, Carl Aage Wangel wrote:

> I wonder if somebody could point me in the right direction
>
> I am to import data to 4D from a plain text document (WordPad) that look
> something like this:
>
> %
>
> DOname;1;20060612;235917; ;
>
> MI13.8;13.8;;;;
>
> ED9;0;31198;30;2;0;;45632;;0;1;
>
> ED10;0;55340;20;2;0;;58512;;0;4;
>
> ED37;0;24258;1;1;0;;1058;;0;5;
>
> ED38;0;25495;1;1;0;;1146;;0;12;
>
> ED39;0;23023;2;1;0;;1012;;0;0;
>
> ED40;0;23759;2;1;0;;1146;;0;7;
>
> ED41;0;24481;2;1;0;;1146;;0;7;
>
> ED42;0;24011;2;1;0;;1146;;0;4;
>
> ED43;0;24078;2;1;0;;1186;;0;8;
>
> ED44;0;24461;2;1;0;;1344;;0;8;
>
> #
>
> The document always start with % and ends with #.
>
> The second line always starts with DO.
>
> The third line always starts with MI.
>
> The followings lines always start with ED.
>
> I imagine I need 3 tables, one for the DO-data, one for the MI-data and one
> for the ED-data. What would be the best way to programmatically catch the
> appropriate data to the various tables? And how would I export a similar
> document?
>
>  
>
> Carl Aage Wangel
>
> **********************************************************************
> Learn by example. Download free 4D 2004 example applications today!
> http://www.4d.com/2004/examples.html
>
> 4th Dimension Internet Users Group (4D iNUG)
> FAQ:  <http://www.4d.com/support/faqnug.html>
> Archive:  <http://dir.gmane.org/gmane.comp.lang.inug-4d.tech>
> Unsub:  mailto:  [hidden email]
> **********************************************************************
>
----------
If a Free Society can not help
the many who are poor it can
not save the few who are rich

J.F. Kennedy - Inaugural Address
**********************************************************************
Learn by example. Download free 4D 2004 example applications today!
http://www.4d.com/2004/examples.html

4th Dimension Internet Users Group (4D iNUG)
FAQ:  <http://www.4d.com/support/faqnug.html>
Archive:  <http://dir.gmane.org/gmane.comp.lang.inug-4d.tech>
Unsub:  mailto:  [hidden email]
**********************************************************************

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Importing data from a text document

Mehboob Alam
In reply to this post by Carl Aage Wangel
If your document is less than 32K, you can use RECEIVE PACKET to read
the document into a text variable. After that, you'd parse the text variable
into lines, i.e. one array element per line, and then parse each line and
create the records according to each line.

Here's some sample code you can learn from
http://www.4d.com/docs/CMU/CMU00104.HTM

As for the structure of the tables, you can get away with having a single
table that can hold any of these lines. Have some extra fields to hold
meta-data, i.e. the line numbers of the data, the date-time the record
was imported, and a field to hold "DO", "MI" or "ED". All the other
data can be stored as real or alphanumeric strings.
 
sincerely,m|a
 
 

"The only reason some people get lost in thought is
because it's unfamiliar territory." -- Paul Fix

----- Original Message ----
From: Carl Aage Wangel <[hidden email]>
To: [hidden email]
Sent: Wednesday, July 12, 2006 2:36:53 PM
Subject: Importing data from a text document

I wonder if somebody could point me in the right direction

I am to import data to 4D from a plain text document (WordPad) that look
something like this:

%

DOname;1;20060612;235917; ;

MI13.8;13.8;;;;

ED9;0;31198;30;2;0;;45632;;0;1;

ED10;0;55340;20;2;0;;58512;;0;4;

ED37;0;24258;1;1;0;;1058;;0;5;

ED38;0;25495;1;1;0;;1146;;0;12;

ED39;0;23023;2;1;0;;1012;;0;0;

ED40;0;23759;2;1;0;;1146;;0;7;

ED41;0;24481;2;1;0;;1146;;0;7;

ED42;0;24011;2;1;0;;1146;;0;4;

ED43;0;24078;2;1;0;;1186;;0;8;

ED44;0;24461;2;1;0;;1344;;0;8;

#

The document always start with % and ends with #.

The second line always starts with DO.

The third line always starts with MI.

The followings lines always start with ED.

I imagine I need 3 tables, one for the DO-data, one for the MI-data and one
for the ED-data. What would be the best way to programmatically catch the
appropriate data to the various tables? And how would I export a similar
document?

 

Carl Aage Wangel

**********************************************************************
Learn by example. Download free 4D 2004 example applications today!
http://www.4d.com/2004/examples.html

4th Dimension Internet Users Group (4D iNUG)
FAQ:  <http://www.4d.com/support/faqnug.html>
Archive:  <http://dir.gmane.org/gmane.comp.lang.inug-4d.tech>
Unsub:  mailto:  [hidden email]
**********************************************************************





**********************************************************************
Learn by example. Download free 4D 2004 example applications today!
http://www.4d.com/2004/examples.html

4th Dimension Internet Users Group (4D iNUG)
FAQ:  <http://www.4d.com/support/faqnug.html>
Archive:  <http://dir.gmane.org/gmane.comp.lang.inug-4d.tech>
Unsub:  mailto:  [hidden email]
**********************************************************************

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

RE: Importing data from a text document

Carl Aage Wangel
In reply to this post by Carl Aage Wangel
Thanks Garri, Chip and m|a for the response. I will try to convert your
suggestions into code.
Thank again
Carl
**********************************************************************
Learn by example. Download free 4D 2004 example applications today!
http://www.4d.com/2004/examples.html

4th Dimension Internet Users Group (4D iNUG)
FAQ:  <http://www.4d.com/support/faqnug.html>
Archive:  <http://dir.gmane.org/gmane.comp.lang.inug-4d.tech>
Unsub:  mailto:  [hidden email]
**********************************************************************

Loading...