Alpha Software Mobile Development Tools:   Alpha Anywhere    |   Alpha TransForm subscribe to our YouTube Channel  Follow Us on LinkedIn  Follow Us on Twitter  Follow Us on Facebook

Announcement

Collapse

The Alpha Software Forum Participation Guidelines

The Alpha Software Forum is a free forum created for Alpha Software Developer Community to ask for help, exchange ideas, and share solutions. Alpha Software strives to create an environment where all members of the community can feel safe to participate. In order to ensure the Alpha Software Forum is a place where all feel welcome, forum participants are expected to behave as follows:
  • Be professional in your conduct
  • Be kind to others
  • Be constructive when giving feedback
  • Be open to new ideas and suggestions
  • Stay on topic


Be sure all comments and threads you post are respectful. Posts that contain any of the following content will be considered a violation of your agreement as a member of the Alpha Software Forum Community and will be moderated:
  • Spam.
  • Vulgar language.
  • Quotes from private conversations without permission, including pricing and other sales related discussions.
  • Personal attacks, insults, or subtle put-downs.
  • Harassment, bullying, threatening, mocking, shaming, or deriding anyone.
  • Sexist, racist, homophobic, transphobic, ableist, or otherwise discriminatory jokes and language.
  • Sexually explicit or violent material, links, or language.
  • Pirated, hacked, or copyright-infringing material.
  • Encouraging of others to engage in the above behaviors.


If a thread or post is found to contain any of the content outlined above, a moderator may choose to take one of the following actions:
  • Remove the Post or Thread - the content is removed from the forum.
  • Place the User in Moderation - all posts and new threads must be approved by a moderator before they are posted.
  • Temporarily Ban the User - user is banned from forum for a period of time.
  • Permanently Ban the User - user is permanently banned from the forum.


Moderators may also rename posts and threads if they are too generic or do not property reflect the content.

Moderators may move threads if they have been posted in the incorrect forum.

Threads/Posts questioning specific moderator decisions or actions (such as "why was a user banned?") are not allowed and will be removed.

The owners of Alpha Software Corporation (Forum Owner) reserve the right to remove, edit, move, or close any thread for any reason; or ban any forum member without notice, reason, or explanation.

Community members are encouraged to click the "Report Post" icon in the lower left of a given post if they feel the post is in violation of the rules. This will alert the Moderators to take a look.

Alpha Software Corporation may amend the guidelines from time to time and may also vary the procedures it sets out where appropriate in a particular case. Your agreement to comply with the guidelines will be deemed agreement to any changes to it.



Bonus TIPS for Successful Posting

Try a Search First
It is highly recommended that a Search be done on your topic before posting, as many questions have been answered in prior posts. As with any search engine, the shorter the search term, the more "hits" will be returned, but the more specific the search term is, the greater the relevance of those "hits". Searching for "table" might well return every message on the board while "tablesum" would greatly restrict the number of messages returned.

When you do post
First, make sure you are posting your question in the correct forum. For example, if you post an issue regarding Desktop applications on the Mobile & Browser Applications board , not only will your question not be seen by the appropriate audience, it may also be removed or relocated.

The more detail you provide about your problem or question, the more likely someone is to understand your request and be able to help. A sample database with a minimum of records (and its support files, zipped together) will make it much easier to diagnose issues with your application. Screen shots of error messages are especially helpful.

When explaining how to reproduce your problem, please be as detailed as possible. Describe every step, click-by-click and keypress-by-keypress. Otherwise when others try to duplicate your problem, they may do something slightly different and end up with different results.

A note about attachments
You may only attach one file to each message. Attachment file size is limited to 2MB. If you need to include several files, you may do so by zipping them into a single archive.

If you forgot to attach your files to your post, please do NOT create a new thread. Instead, reply to your original message and attach the file there.

When attaching screen shots, it is best to attach an image file (.BMP, .JPG, .GIF, .PNG, etc.) or a zip file of several images, as opposed to a Word document containing the screen shots. Because Word documents are prone to viruses, many message board users will not open your Word file, therefore limiting their ability to help you.

Similarly, if you are uploading a zipped archive, you should simply create a .ZIP file and not a self-extracting .EXE as many users will not run your EXE file.
See more
See less

Need help getting data into a table

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Need help getting data into a table

    I need some suggestions in how to unravel a text file.

    This particular file is output from the Federal Reserve's wire transfer program. Each record is a variable length record (no problem). They use field identifiers that are structured like this {xxxx} where the xxxx is a 4 digit number. This code {XXXX} identifies a particular field depending on what the code is.
    \
    For example, a record might look something like this--{1000}20090605112243TFY{1500}Tommy Thompson{1510}915 Thompson Road{1520}Springville Tn{1530}38256

    {1000}=Unique ID {1500}= Name {1510}= Address and so on.

    Obviously, this is a variable length record with variable length fields.

    Still no problem. I have been able to successfully parse the record and extract both the code {xxxx} and it's corresponding field. As of right now, I'm outputting a text file that looks like this. unique id,code,fieldname. I drop the brackets so the actual file would look like this.

    20090605112243TFY,1500,Tommy Thompson
    20090605112243TFY,1510,915 Thompson Road
    Etc

    There are only a certain number of the codes {xxxx} and I have the documentation from the Fed. There are probably 25 or 30 such unique codes.

    Where I could use some help is how to get this info into a table. I would like to do it as efficiently as possible.

    I would like to have a table that has fields for the unique ID and each of the possible codes (25-30) and some how post to it. Either from the text file I build, or a dbf table created by an import of the text file.

    Any suggestions?
    Tommy Thompson
    Thompson Consulting Services
    Beautiful Kentucky Lake, Springville, TN 38256
    [email protected]


    #2
    Re: Need help getting data into a table

    Tommy,
    I think that if you could keep the entire record on one comma delimited line per record it would be much easier.

    A couple of things that need to be known...
    Does the data come across with All the codes even if no data for the code?
    Does the data come across as single records or as you show after parsing as multiple lines for the same record?

    IOW, need to know the consistency of the data--the original format AND also the exact format you want to end up with.
    Mike
    __________________________________________
    It is only when we forget all our learning that we begin to know.
    It's not what you look at that matters, it's what you see.
    Henry David Thoreau
    __________________________________________



    Comment


      #3
      Re: Need help getting data into a table

      Originally posted by MikeC View Post
      Tommy,
      I think that if you could keep the entire record on one comma delimited line per record it would be much easier.

      A couple of things that need to be known...
      Does the data come across with All the codes even if no data for the code?

      No, only the fields that happen to be used for a given record. There might be 10 codes in one record and 12 in another.


      Does the data come across as single records or as you show after parsing as multiple lines for the same record?

      It comes across as single records. I break out each record into a string and parse it. I have put the new text fileout as one string delimited by | (can't use commas since they are in the fields. ex Anywhere,TN) I also put it out the way described in my post. This is a temporary file.

      IOW, need to know the consistency of the data--the original format AND also the exact format you want to end up with.

      I cannot show the actual data for security reasons, but the file is a variable length record length with variable length fields. Each field preceding by a 6 character identifier. There is a fixed length unique ID at the beginning of each record. the rest of the record is code,field,code,field,code,field. There is not a consistent length since each record can contain any number of code,field combinations. All that said, I have that part worked out. The question is, is there some dynamic way to read and post. I know I can do 30 compares (if code = 1500, then do something) I was mainly looking for something more elegant.

      The final table will look like this:

      Unique_Code
      Code1
      Code2
      .
      .
      .
      Code30
      Tommy Thompson
      Thompson Consulting Services
      Beautiful Kentucky Lake, Springville, TN 38256
      [email protected]

      Comment


        #4
        Re: Need help getting data into a table

        Instead of using a table for the code lookups, why not use an array. Create it once and use it over and over in order to translate a code number into a field name. Something like this:

        Code:
        dim codes[1500..2000] as C
        codes[1500] = "Name"
        codes[1510] = "Address"
        codes[1520] = "City"
        
        'translate code into fieldname:
        ?codes[1510]
        = "Address"
        It seems to me that if you could generate a string that contains the fieldnames and the field values you ought to be able to use the property_from_string() function to insert new records in your table. This will require careful formatting of the string.

        If you wanted to work with your method for parsing the input string you could loop through each line of the text file you are creating, keeping track of the unique_id. Begin a new record when the id changes, after committing the previous record to disk. As each line is processed you'd translate the code into a fieldname using the previously define array. Here's an example using AlphaSports, showing how to use the fieldname you get from the array in the context of entering a new record.

        Code:
        t = table.open("customer")
        dim fld_ptr as P
        dim fld as C
        fld = "lastname"   'fld is the field name obtained from codes array
        
        t.enter_begin()
        fld_ptr = t.field_get(fld)  'establish pointer to a field
        fld_ptr.value_put("Smith")   'assign field value to the field pointer
        t.enter_end(.t.)
        ?t.lastname
        = "Smith               "

        Comment


          #5
          Re: Need help getting data into a table

          Since you know that each code belongs to a particular field you can loop through the file grabbing each line (as you probably already are) and use code similar to this
          Code:
          dim t as P
          t=table.open("customer")
          dim scource_line as C
          
          [COLOR="Blue"]'start of loop[/COLOR]
          scource_line = "{1000}20090605112243TFY{1500}Tommy Thompson{1510}915 Thompson Road{1520}Springville Tn{1530}38256"
          scource_line = scource_line + "{"  [COLOR=Blue]'adds a { to delimit the last field value
          [/COLOR]
          
          t.enter_begin()
          t.Company = extract_string(scource_line,"{1000}","{")
          t.Lastname = extract_string(scource_line,"{1500}","{")
          t.Bill_address_1 = extract_string(scource_line,"{1510}","{")
          t.Bill_city = extract_string(scource_line,"{1520}","{")
          t.Bill_postal_code = extract_string(scource_line,"{1530}","{")
          [COLOR=Black]t.Phone = extract_string(scource_line,"{1540}","{")[/COLOR]   [COLOR=Blue]'there is no {1540} so nothing is entered[/COLOR]
          [COLOR=RoyalBlue]'....additional lines for the rest of the codes[/COLOR]
          t.enter_end()
          [COLOR="Blue"]'end of loop[/COLOR]
          
          t.close()
          This adds a new record to the customer table in Alpha sports. If any of the codes are missing from the scource they simply won't be found and nothing is entered.
          Last edited by Tim Kiebert; 06-14-2009, 06:58 PM.
          Tim Kiebert
          Eagle Creek Citrus
          A complex system that does not work is invariably found to have evolved from a simpler system that worked just fine.

          Comment


            #6
            Re: Need help getting data into a table

            Many thanks to all of you. I believe I have what I need. I'll try to remember to post the final result in case anyone else runs into a similar situation.
            Tommy Thompson
            Thompson Consulting Services
            Beautiful Kentucky Lake, Springville, TN 38256
            [email protected]

            Comment

            Working...
            X