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

Removing characters from text field

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

    Removing characters from text field

    I am importing a text file into a table.
    The trouble is that the text file has the single-quote character at the beginning and ending of some fields.
    Sometimes it's on a character-field or sometimes a number-field but it doesn't apply using any logic that makes sense to me.

    How do I remove the single-quote character from either the original text file or from the table created when I import that text file ?
    I can personally use Notepad to clean up the mess but I need something automated so my customers can do it.

    Thanks for the help.

    #2
    Re: Removing characters from text field

    remspecial() comes to mind.

    If using notepad, replace works like " with nothing
    Dave Mason
    [email protected]
    Skype is dave.mason46

    Comment


      #3
      Re: Removing characters from text field

      That did the trick. Thanks Dave.

      Comment


        #4
        Re: Removing characters from text field

        Originally posted by John Cunradi View Post
        That did the trick. Thanks Dave.
        Did you use remspecial()?

        It's a great function, but may remove more than you want. Especially in a comma delimited file...

        Another option is strtran() or it's other variations.

        Glad to hear it's working for you.
        Al Buchholz
        Bookwood Systems, LTD
        Weekly QReportBuilder Webinars Thursday 1 pm CST

        Occam's Razor - KISS
        Normalize till it hurts - De-normalize till it works.
        Advice offered and questions asked in the spirit of learning how to fish is better than someone giving you a fish.
        When we triage a problem it is much easier to read sample systems than to read a mind.
        "Make it as simple as possible, but not simpler."
        Albert Einstein

        http://www.iadn.com/images/media/iadn_member.png

        Comment


          #5
          Re: Removing characters from text field

          Hi Al,
          Quick question:
          In a fixed width text file, is there an A5 function that can insert a special character to use as a delimiter before importing to a table?
          Robin

          Discernment is not needed in things that differ, but in those things that appear to be the same. - Miles Sanford

          Comment


            #6
            Re: Removing characters from text field

            Originally posted by MoGrace View Post
            Hi Al,
            Quick question:
            In a fixed width text file, is there an A5 function that can insert a special character to use as a delimiter before importing to a table?
            Quick response - why?

            You can map the import for a file with fixed width fields and save it for future use.
            Al Buchholz
            Bookwood Systems, LTD
            Weekly QReportBuilder Webinars Thursday 1 pm CST

            Occam's Razor - KISS
            Normalize till it hurts - De-normalize till it works.
            Advice offered and questions asked in the spirit of learning how to fish is better than someone giving you a fish.
            When we triage a problem it is much easier to read sample systems than to read a mind.
            "Make it as simple as possible, but not simpler."
            Albert Einstein

            http://www.iadn.com/images/media/iadn_member.png

            Comment


              #7
              Re: Removing characters from text field

              Here's what I do.

              Code:
              in_fil = file.open("P:\executive\hdb\mdi tbl\statement.txt",FILE_RW_EXCLUSIVE)
              out_fil = file.create("P:\executive\hdb\mdi tbl\stmt_impt.txt",FILE_RW_EXCLUSIVE)
              msk = space(6)+"~"+space(40)+"~"+space(30)+"~"+space(20)+"~"+space(2)+"~"+space(5)+"~"+space(8)+"~"+space(5)+"~"+space(9)+"~"
              msk = msk+space(1)+"~"+space(14)+"~"+space(8)+"~"+space(8)+"~"+space(5)
              while .not. in_fil.eof()
              	in_ln = in_fil.read_line()
              	out_ln = mask(in_ln,msk)
              	out_fil.write_line(out_ln)
              end while
              out_fil.flush()
              out_fil.close()
              in_fil.close()
              The input file has no delimiters, just one long line of characters per record. The fields map to the space(#) positions in the msk variable. The file. methods are very fast.
              There can be only one.

              Comment


                #8
                Re: Removing characters from text field

                Originally posted by Al Buchholz View Post
                Quick response - why?

                You can map the import for a file with fixed width fields and save it for future use.
                I know I am supposed to be able to do this, but when I tried it the import genie skewed the data and I could not get it mapped correctly (v11). Apparently a space between fields is not enough for the genie unless character fields are also in quotes.
                Robin

                Discernment is not needed in things that differ, but in those things that appear to be the same. - Miles Sanford

                Comment


                  #9
                  Re: Removing characters from text field

                  Hi Stan,
                  A mask? How clever is that! I take it the space() is the field size in the text file... so many functions I have never found!

                  Thank you!

                  I have an old DOS inventory program we use and cannot get any data out of it except thru its reports, this will be a big help.

                  Have you got one for removing the (fixed) headers and printer control codes too?
                  Robin

                  Discernment is not needed in things that differ, but in those things that appear to be the same. - Miles Sanford

                  Comment


                    #10
                    Re: Removing characters from text field

                    Not sure what control codes would be found. Be glad to look at a sample file.

                    As for headers, you know how many header lines there are each time? Read them and don't write them....

                    Code:
                    in_fil = file.open("P:\executive\hdb\mdi tbl\statement.txt",FILE_RW_EXCLUSIVE)
                    out_fil = file.create("P:\executive\hdb\mdi tbl\stmt_impt.txt",FILE_RW_EXCLUSIVE)
                    msk = space(6)+"~"+space(40)+"~"+space(30)+"~"+space(20)+"~"+space(2)+"~"+space(5)+"~"+space(8)+"~"+space(5)+"~"+space(9)+"~"
                    msk = msk+space(1)+"~"+space(14)+"~"+space(8)+"~"+space(8)+"~"+space(5)
                    while .not. in_fil.eof()
                    'three header lines to be discarded
                    	for qx = 1 to 3
                    	in_fil.read_line()
                    	next qx
                    	'now ready for line 4 of the original file, good data starts
                    	in_ln = in_fil.read_line()
                    	out_ln = mask(in_ln,msk)
                    	out_fil.write_line(out_ln)
                    end while
                    out_fil.flush()
                    out_fil.close()
                    in_fil.close()
                    Which naturally enough leads us to adding our own header line of field names.

                    Code:
                    in_fil = file.open("P:\executive\hdb\mdi tbl\statement.txt",FILE_RW_EXCLUSIVE)
                    out_fil = file.create("P:\executive\hdb\mdi tbl\stmt_impt.txt",FILE_RW_EXCLUSIVE)
                    msk = space(6)+"~"+space(40)+"~"+space(30)+"~"+space(20)+"~"+space(2)+"~"+space(5)+"~"+space(8)+"~"+space(5)+"~"+space(9)+"~"
                    msk = msk+space(1)+"~"+space(14)+"~"+space(8)+"~"+space(8)+"~"+space(5)
                    'write a field name header line
                    hd_ln = "Id~name~addr~city~st~zip~occupation"
                    out_fil.write_ln(hd_ln)
                    while .not. in_fil.eof()
                    'three header lines to be discarded
                    	for qx = 1 to 3
                    	in_fil.read_line()
                    	next qx
                    	'now ready for line 4 of the original file, good data starts
                    	in_ln = in_fil.read_line()
                    	out_ln = mask(in_ln,msk)
                    	out_fil.write_line(out_ln)
                    end while
                    out_fil.flush()
                    out_fil.close()
                    in_fil.close()
                    Last edited by Stan Mathews; 02-05-2015, 02:32 PM.
                    There can be only one.

                    Comment


                      #11
                      Re: Removing characters from text field

                      There's a lot of great ideas here. here' the code that worked as an expression of an update: remspecial(Scanning_Upc_)

                      Comment


                        #12
                        Re: Removing characters from text field

                        Originally posted by MoGrace View Post
                        I know I am supposed to be able to do this, but when I tried it the import genie skewed the data and I could not get it mapped correctly (v11). Apparently a space between fields is not enough for the genie unless character fields are also in quotes.
                        Did you try the table format instead of character delimited? (and did you skip the genie and use the create button instead? with the Table ASCII option)

                        Stan always has a cool way of fixing stuff......
                        Al Buchholz
                        Bookwood Systems, LTD
                        Weekly QReportBuilder Webinars Thursday 1 pm CST

                        Occam's Razor - KISS
                        Normalize till it hurts - De-normalize till it works.
                        Advice offered and questions asked in the spirit of learning how to fish is better than someone giving you a fish.
                        When we triage a problem it is much easier to read sample systems than to read a mind.
                        "Make it as simple as possible, but not simpler."
                        Albert Einstein

                        http://www.iadn.com/images/media/iadn_member.png

                        Comment


                          #13
                          Re: Removing characters from text field

                          @ Stan: Here is an example report from 2011 no less (shows how long I have been trying to do this... ;) Its already a bit cleaned up but the control code appears on line 61 & 102 - it is chr(12) I think for FF. Notice the header on page 1 is 12 lines, but on page 2 it is 11. The footer is consistent at 5 lines at the end followed by another FF.

                          EXAMPLE.TXT

                          @ AL: No I didn't try it without the genie, but I will...

                          @ John: Hope you don't mind me cutting in on your thread...seemed related to me!
                          Robin

                          Discernment is not needed in things that differ, but in those things that appear to be the same. - Miles Sanford

                          Comment


                            #14
                            Re: Removing characters from text field

                            Originally posted by MoGrace View Post
                            @ Stan: Here is an example report from 2011 no less (shows how long I have been trying to do this... ;) Its already a bit cleaned up but the control code appears on line 102 - it is chr(12) I think for FF. Notice the header on page 1 is 12 lines, but on page 2 it is 11. The footer is consistent at 5 lines at the end followed by another FF.

                            [ATTACH]39691[/ATTACH]

                            @ AL: No I didn't try it without the genie, but I will...
                            It's more than a 'normal' import.

                            Gonna need some line by line processing either prior to the import or record selecting after an import. Seeing some blank values in the first field when it's not a data line.
                            Or you want the first field to have a length of 1 and select if the value is I....
                            Al Buchholz
                            Bookwood Systems, LTD
                            Weekly QReportBuilder Webinars Thursday 1 pm CST

                            Occam's Razor - KISS
                            Normalize till it hurts - De-normalize till it works.
                            Advice offered and questions asked in the spirit of learning how to fish is better than someone giving you a fish.
                            When we triage a problem it is much easier to read sample systems than to read a mind.
                            "Make it as simple as possible, but not simpler."
                            Albert Einstein

                            http://www.iadn.com/images/media/iadn_member.png

                            Comment


                              #15
                              Re: Removing characters from text field

                              I am working out the pseudo code to figure out the steps I need to take...brb

                              Using Another Notepad, I can see there are 103 total lines in the file - the last line is blank as is the first line.

                              The header is a consistent 11 lines on each page
                              Each page has 60 lines or less followed by a FF line
                              The Footer is 4 lines and only appears at the end, followed by a FF and blank line.

                              Removing the first and last blank lines would be first

                              Finding the control codes - chr(12) and removing them would be next.

                              Now I can get a line_count for the remaining file and remove the last 4 lines of the footer
                              and update the linecount. Also my page line count is now reduced by 2 - for the initial blank and the FF at the end makes my first page 59 lines instead of 61 (counting the FF as a line)

                              So by using FOR...NEXT I should be able to skip the headers like Stan showed and write the masked data to a file ready for importing.

                              Hopefully this will also work on a longer report....otherwise I might be able to take a page at a time in my script and append each page to the output file?

                              The bigger problem now is to get my users to input the data in the DOS program correctly.
                              That 'date' field in the report is actually tagged onto the Yard Desc field and the 'Lot" field is a combination of Lot No and Vendor ID. But its a start!
                              Last edited by MoGrace; 02-05-2015, 02:41 PM.
                              Robin

                              Discernment is not needed in things that differ, but in those things that appear to be the same. - Miles Sanford

                              Comment

                              Working...
                              X