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

Import Multiple file

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

    Import Multiple file

    I currently have an import script that works on one file. I need it to import multiple files from one directory. The catch is i only want to import the ones that have _hdr at the end of the file name. All file extensions are .txt.

    Any help would be greatly appreciated.

    Regards,
    Beau

    #2
    Re: Import Multiple file

    Would it be too much to ask to show us the script you have now so we could suggest modifications or do you want us to guess

    the name of the table being imported to
    the path to the files to be imported
    the number of and names of the fields to be imported
    the file type being imported
    There can be only one.

    Comment


      #3
      Re: Import Multiple file

      The FILEFIND.GET() method creates a CR-LF delimited string with information about the files in a directory that match a pattern.
      list = filefind.get("f:\a5v5\*_hdr.*",0,"PN")

      will return a list of all the files on the F drive in the a5v5 folder that have "_hdr" immediately preceeding the . in the filename.ext.

      The FOR EACH ... NEXT operators allow you to step through a list, collection, or array without knowing the number of elements that it contains.
      so if you modify your script to make the first line (setting the appropriate drive and path)

      list = filefind.get("f:\a5v5\*_hdr.*",0,"PN")
      for each entry in list
      'your present import script here
      next

      you only need change the line in your present script

      import.file = somethingherenow
      to

      import.file = entry
      There can be only one.

      Comment


        #4
        Re: Import Multiple file

        hi stan,

        thanks for the reply, here is the script made from the import builder.

        Code:
        temporary_import_table = file.temp_path_get()+ "partqahead_temp_table.dbf"
        import_destination_table = "partqahead"
        
        import_filename = filename_decode("[PathAlias.ADB_Path]\results\601 hsg_360-10_hdr.txt")
        if file.exists(import_filename) = .f. then
        	ui_msg_box("Error","File to import not found: '"+import_filename+"'.",ui_stop_symbol)
        	end
        end if
        
        
        ON ERROR GOTO ERROR20022011004819405
        
        
        import.type = 0
        import.names = "use"
        import.file = import_filename
        import.db = temporary_import_table
        import.skip_lines = 0
        import.skip_bytes = 0
        import.field_sep = "<TAB>"
        import.record_sep = "<CR><LF>"
        import.text_qualifier = ""
        import.record_len = 0
        import.rem_blanks = .F.
        import.escape_newlines = .F.
        import.import_encoding = "default"
        import.fields = 7
        import.field1 = "partid,c,0,7,0"
        import.field2 = "serialid,c,1,6,0"
        import.field3 = "operator,c,3,6,0"
        import.field4 = "device,c,7,7,0"
        import.field5 = "software,c,11,7,0"
        import.field6 = "softvers,c,12,6,0"
        import.field7 = "drwno,c,20,13,0"
        import()
        
        
        a_tbl = table.open(import_destination_table)
        append.t_db = temporary_import_table
        append.m_key = ""
        append.t_key = ""
        append.m_filter = ""
        append.t_filter = ""
        append.type = "All"
        append.m_count = 7
        append.m_field1 = "PARTID"
        append.m_exp1 = "@partqahead_temp_table->PARTID"
        append.m_field2 = "SERIALID"
        append.m_exp2 = "@partqahead_temp_table->SERIALID"
        append.m_field3 = "OPERATOR"
        append.m_exp3 = "@partqahead_temp_table->OPERATOR"
        append.m_field4 = "DEVICE"
        append.m_exp4 = "@partqahead_temp_table->DEVICE"
        append.m_field5 = "SOFTWARE"
        append.m_exp5 = "@partqahead_temp_table->SOFTWARE"
        append.m_field6 = "SOFTVERS"
        append.m_exp6 = "@partqahead_temp_table->SOFTVERS"
        append.m_field7 = "DRWNO"
        append.m_exp7 = "@partqahead_temp_table->DRWNO"
        append.t_count = 0
        a_tbl.append()
        
        
        GOTO CONTINUE20022011004819405
        ERROR20022011004819405:
        ON ERROR GOTO 0
        ui_msg_box("Error","Error running Import Operation"+crlf()+error_text_get())
        END
        CONTINUE20022011004819405:
        
        a_tbl.close()
        
        'In case the destination table is not already in the Database, add it...
        file_add_to_db(table.filename_get(import_destination_table))
        'If the Operation is run from within a Form or Browse, then refresh the window
        if is_object(topparent.this) then
        	if topparent.Class() = "form" .or. topparent.class() = "browse" then
        		topparent.Refresh_layout()
        	end if
        end if

        Comment


          #5
          Re: Import Multiple file

          Thanks for your help stan i managed to get it working. at the end of each file there is an end record, is there any way of omitting this from the import?

          Beau

          Comment


            #6
            Re: Import Multiple file

            I don't think you can omit it from the import but you can easily delete it.

            Inside the for each...next loop but after the append insert


            Code:
            b_tbl = table.open("partqahead")
            b_tbl.fetch_last()
            b_tbl.change_begin()
            b_tbl.delete()
            b_tbl.change_end(.T.)
            b_tbl.close(()

            This will delete the last record after each import.
            There can be only one.

            Comment


              #7
              Re: Import Multiple file

              Stan is absolutely correct with his answer to your question. However, I suggest that you should check that the last record is blank before deleting.

              Code:
              b_tbl = table.open("partqahead")
              b_tbl.fetch_last()
              if alltrim(b_tbl.[COLOR="Red"]somefield[/COLOR]) = "" then
                  b_tbl.change_begin()
                  b_tbl.delete()
                  b_tbl.change_end(.T.)
              end if
              b_tbl.close()
              where somefield is changed to a field name that you know will (should?) contain a value in the import.

              Comment

              Working...
              X