Hot Topic (More than 10 Replies) Importing Flat File to Main & Sub Forms (Read 1621 times)
SpencerWulwick
Senior Member
Members
*****
Offline



Posts: 677
Location: Wilton Manors, Florida
Joined: Jan 16th, 2005
Importing Flat File to Main & Sub Forms
Jan 30th, 2006 at 12:51am
Print Post Print Post  
Hi -

I am back to further discuss a CD database (although I am actually applying this to something totally different).

Suppose I have a Q&A database that has two pages.

Page 1 contains all the information about the CD e.g. Title, Music Category, Date Purchased, Where Stored, General Comments, and several other fields (20 in all).

Page 2 contains separate line items for each track, eg. Track #, Song Title, Artist, Time, Comments.  It is set up something like:

TNO1:     ST1:      A1:       T1:      C1:
TNO2:     ST2:      A2:       T2:      C2:
TNO3:     ST3       A3:        T3:      C3:

and so on through 25 "line items" for each potential track.  (Some forms may have 8 tracks, some 15, some 23 and so on - up to 25).

The newly created Sesame file contains all of the information from page 1 on the main form and has a sub-form to contain all of the information from each of the tracks.

My question is how can I export the information from the Q&A file into the Sesame database, so that each track will be in a separate record on the sub-form.

It seems to me that the ASCII text file has to have all of the main form info, followed by the first track info, followed by all of the main form info, followed by the second track info, followed by all the main form info, followed by the third track info  ... and so on, and so on, and so on.

How do I accomplish this, since I cannot set up an export spec to alternately repeat the values from page 1 of my Q&A database?

Thank you!
  

- Spencer

    ** Practice random kindness & senseless acts of beauty!
Back to top
IP Logged
 
Bob_Hansen
Senior Member
Members
*****
Offline


WOW, They have the Internet
on computers now!

Posts: 1861
Location: Salem, NH
Joined: Nov 24th, 2002
Re: Importing Flat File to Main & Sub Forms
Reply #1 - Jan 30th, 2006 at 8:02am
Print Post Print Post  
I know that you are working on a method within Q&A to include the "header" in front of each subrecord. 
I am trying to accomplish the same thing from a different direction.

My approach involves doing a Search/Replace in another program.

In Q&A add a new field before each "sub record", except the first one.
Mass Update and place a tilde "~" in that field
Export every field from Q&A in sequence

Now open the exported file in a text editor/word processor, etc.
Do a Search/Replace for "~" and replace with an end of line, followed by The "header in front

Sample:
Start with:
Header Record1~Record2~Record3~Record4

Replace ~ with NewLine Header

End with:
Header Record1
Header Record2
Header Record3
Header Record4

Instead of using Word,   I use a text editor with Regular Expressions for Search and Relace.  Routine looks something like this:

Search for:  (.*)~(.*)~(.*)~(.*)~(.*)
Replace with: \1\2\n\1\3\n\1\4\n\1\5

There are many variations of Regular Expressions so your syntax may vary somewhat. 
In the expression above, \1 = Header, \n = end of line, \2, \3, \4, \5 each represent the next consecutive block of text within the ( ) marks.

I may have a working sample for you to review tomorrow.
« Last Edit: Jan 30th, 2006 at 10:33am by Bob_Hansen »  



Bob Hansen
Sesame Database Manager Professional
Sensible Solutions Inc.
Salem, NH
603-898-8223
Skype ID = sensiblesolutions
Back to top
IP Logged
 
Bob_Hansen
Senior Member
Members
*****
Offline


WOW, They have the Internet
on computers now!

Posts: 1861
Location: Salem, NH
Joined: Nov 24th, 2002
Re: Importing Flat File to Main & Sub Forms
Reply #2 - Jan 30th, 2006 at 10:32am
Print Post Print Post  
Hi Spencer,  I have a flat file that imports into Sesame by using the technique above.  No extra programming or Mass Updates in Q&A.........BUT......one problem.

The destination Sesame parent form has three subforms on it.  I was just importing into two of them, but find that there appears to be an issue with multiple subfoms. 

Only expected one record in subform2 but got 3 more duplicate records, I suspect because 4 records were recorded in the subform1.

IS there a restriction that we can only import hierarchical records into parent that may be  limited to a single subform?

If yes, any suggestions on how to work around that?

----------------------------------------------------------------
There is also an issue with two or more records in Q&A for same parent.  They come in to Sesame as separate parent records, not surprising, but what is really needed are the subform portions, not duplicate parents. 

Any ideas on combining multiple parent Q&A records before exporting or a way to merge them in the export file before importing?  Maybe need to do some type of XLU to fill in subrecords in one of the parents, and then delete the extra parent records?

  



Bob Hansen
Sesame Database Manager Professional
Sensible Solutions Inc.
Salem, NH
603-898-8223
Skype ID = sensiblesolutions
Back to top
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: Importing Flat File to Main & Sub Forms
Reply #3 - Jan 30th, 2006 at 1:04pm
Print Post Print Post  
Bob,

I believe you can import into multiple subforms, but you have to get the format correct so that Sesame can figure out what you are trying to do.

Take your form that has the multiple subforms and do a hierarchical export from it using the same fields you want to import. Look at the file it produces. That will tell you what format you need to get your Q&A data into.
  

- Hammer
The plural of anecdote is not data.
Back to top
IP Logged
 
Bob_Hansen
Senior Member
Members
*****
Offline


WOW, They have the Internet
on computers now!

Posts: 1861
Location: Salem, NH
Joined: Nov 24th, 2002
Re: Importing Flat File to Main & Sub Forms
Reply #4 - Jan 30th, 2006 at 5:59pm
Print Post Print Post  
Good sugestion Erika, as usual.........I will probably get to that tonight.  Maybe Spencer will have better success before then.....

My original export files had parent LEs in middle of subform LEs.  These are things I had to do, just to get multiple records on the subforms to show up, nevermind the extra unwanted records.

Up to now, I did have to rearrange the data so that all the Parent data was grouped together by itself, I had to eliminate some data fields that I had marked as IGNORED in the Import Spec, and I had to move all of each subformx items together as a group. 



  



Bob Hansen
Sesame Database Manager Professional
Sensible Solutions Inc.
Salem, NH
603-898-8223
Skype ID = sensiblesolutions
Back to top
IP Logged
 
SpencerWulwick
Senior Member
Members
*****
Offline



Posts: 677
Location: Wilton Manors, Florida
Joined: Jan 16th, 2005
Re: Importing Flat File to Main & Sub Forms
Reply #5 - Jan 30th, 2006 at 8:55pm
Print Post Print Post  
ARGGGH!

Seems like I take one step forward and ten steps back on this project.

Can anyone tell me why the import function simply won't work at all?

I click on import, select an ASCII text file (which I've done hundreds, if not thousands of times) ... and NOTHING happens.  No error messages, no message at the bottom of the Sesame database, NO IMPORT, NO NOTHING.

Anyone have any ideas why this might happen?
  

- Spencer

    ** Practice random kindness & senseless acts of beauty!
Back to top
IP Logged
 
Ray the Reaper
Global Moderator
Members
Lantica Support
*****
Offline


The One & The Only

Posts: 2482
Joined: Aug 20th, 2003
Re: Importing Flat File to Main & Sub Forms
Reply #6 - Jan 30th, 2006 at 8:56pm
Print Post Print Post  
Hello Spencer,

Have you set up/or loaded an Import Spec? If you have not set any elements for the imported data to go into, you will get what you are seeing.

-Ray
  

Raymond Yoxall Consulting
ray.yoxall@gmail.com
ryoxall@lantica.com
Sesame Applications, Design and Support
Back to top
IP Logged
 
SpencerWulwick
Senior Member
Members
*****
Offline



Posts: 677
Location: Wilton Manors, Florida
Joined: Jan 16th, 2005
Re: Importing Flat File to Main & Sub Forms
Reply #7 - Jan 30th, 2006 at 9:22pm
Print Post Print Post  
Ray -

You'll excuse me if I don't tell you whether you are right or not.

I am far too embarrassed.  Undecided
« Last Edit: Jan 30th, 2006 at 10:29pm by SpencerWulwick »  

- Spencer

    ** Practice random kindness & senseless acts of beauty!
Back to top
IP Logged
 
Ray the Reaper
Global Moderator
Members
Lantica Support
*****
Offline


The One & The Only

Posts: 2482
Joined: Aug 20th, 2003
Re: Importing Flat File to Main & Sub Forms
Reply #8 - Jan 30th, 2006 at 9:32pm
Print Post Print Post  
Quote:
Ray -

You'll excuse me if I don't tell you wether you are right or not.

I am far too embarrassed.  Undecided



You are excused. Don't be too embarrassed, It happens to everyone from time to time.

-Ray
  

Raymond Yoxall Consulting
ray.yoxall@gmail.com
ryoxall@lantica.com
Sesame Applications, Design and Support
Back to top
IP Logged
 
The Cow
YaBB Administrator
*****
Offline



Posts: 2530
Joined: Nov 22nd, 2002
Re: Importing Flat File to Main & Sub Forms
Reply #9 - Jan 30th, 2006 at 9:41pm
Print Post Print Post  
Yeah, I can't find a single Q&A (or now Sesame) database without a couple of records that look an awful lot like search specs.
  

Mark Lasersohn&&Programmer&&Lantica Software, LLC
Back to top
IP Logged
 
Bob_Hansen
Senior Member
Members
*****
Offline


WOW, They have the Internet
on computers now!

Posts: 1861
Location: Salem, NH
Joined: Nov 24th, 2002
Re: Importing Flat File to Main & Sub Forms
Reply #10 - Jan 30th, 2006 at 10:47pm
Print Post Print Post  
OK, I did an export of a Parent form with three subforms and have ended up with the following conclusions for coming up with an import file layout structure:

1.  Import file for parent and subforms will be fixed NUMBER of fields.
2.  Structure is Parent..Subform1 fields or blanks..Subform2 fields or blanks..Subform3 fields or blanks.
3.  There will be a separate line for each individual record for all subforms.  Count the total subrecords, and that is how many lines should exist.

Sample file layout for one Parent form with 4 subforms (SF1,SF2,SF3,SF4), three data fields(a,b,c) each:

Parent Fields,SF1a,SF1b,SF1c,,,,,,,,,,
Parent Fields,,,,SF2a,SF2b,SF2c,,,,,,,
Parent Fields,,,,,,,SF3a,SF3b,SF3c,,,,
Parent Fields,,,,,,,,,,SF4a,SF4b,SF4c,

------------------------------------------------
Hope this helps someone else to create an import file that includes hierarchical subform records.
And if this layout structure is not correct, Mark/Erika/Ray will correct me.

  



Bob Hansen
Sesame Database Manager Professional
Sensible Solutions Inc.
Salem, NH
603-898-8223
Skype ID = sensiblesolutions
Back to top
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: Importing Flat File to Main & Sub Forms
Reply #11 - Jan 30th, 2006 at 10:55pm
Print Post Print Post  
Looks right to me. It makes sense based on what I know the Import code to be doing when trying to figure out which fields belong to which subrecords.
  

- Hammer
The plural of anecdote is not data.
Back to top
IP Logged
 
Ray the Reaper
Global Moderator
Members
Lantica Support
*****
Offline


The One & The Only

Posts: 2482
Joined: Aug 20th, 2003
Re: Importing Flat File to Main & Sub Forms
Reply #12 - Jan 30th, 2006 at 10:59pm
Print Post Print Post  
Hello Bob,

Looks right to me. Only problem I see is that there appears to be an extra comma at the end of each line. So the Last line would be
Parent Fields,,,,,,,,,,SF4a,SF4b,SF4c

-Ray
  

Raymond Yoxall Consulting
ray.yoxall@gmail.com
ryoxall@lantica.com
Sesame Applications, Design and Support
Back to top
IP Logged
 
SpencerWulwick
Senior Member
Members
*****
Offline



Posts: 677
Location: Wilton Manors, Florida
Joined: Jan 16th, 2005
Re: Importing Flat File to Main & Sub Forms
Reply #13 - Jan 31st, 2006 at 1:58am
Print Post Print Post  
Hi -

Hip Hip Hooray.  After about 3 days of living and breathing this "problem," I finally did it.

Was finally able to import the "communal" data from a Q&A form to the parent form in Sesame and each of the field rows in Q&A to a separate sub-form record in Sesame. 

If anyone is interested in knowing how, feel free to ask or to contact me directly. 

At least now I know, for absolutely certain, that it is definiely do-able.
  

- Spencer

    ** Practice random kindness & senseless acts of beauty!
Back to top
IP Logged
 
Bob_Hansen
Senior Member
Members
*****
Offline


WOW, They have the Internet
on computers now!

Posts: 1861
Location: Salem, NH
Joined: Nov 24th, 2002
Re: Importing Flat File to Main & Sub Forms
Reply #14 - Jan 31st, 2006 at 2:20am
Print Post Print Post  
Well done Spencer....great job.

You have essentially made Q&A add the Parent info as header to each group of sub form records fields,.

And now that I understand  the desired import format for flat file to hierarchical structure, I should be able to use your technique with some modifications for multiple sub forms coming from the flat form.
  



Bob Hansen
Sesame Database Manager Professional
Sensible Solutions Inc.
Salem, NH
603-898-8223
Skype ID = sensiblesolutions
Back to top
IP Logged