Alpha Video Training
Page 2 of 2 FirstFirst 12
Results 31 to 53 of 53

Thread: Importing Fractions in a String?

  1. #31
    "Certified" Alphaholic Keith Hubert's Avatar
    Real Name
    Keith Hubert
    Join Date
    Jul 2000
    Location
    London, UK
    Posts
    6,930

    Default Re: Importing Fractions in a String?

    Hi Tom,

    Because the 8th fractions are special characters they do not get saved in the CSV file. Just "?" the same as Alpha import.
    Regards
    Keith Hubert
    Alpha Guild Member
    London.
    KHDB Management Systems
    Skype = keith.hubert


    For your day-to-day Needs, you Need an Alpha Database!

  2. #32
    "Certified" Alphaholic
    Real Name
    Andrew Schone
    Join Date
    Dec 2005
    Location
    Kansas
    Posts
    1,047

    Default Re: Importing Fractions in a String?

    If you wish to drop it to a text file you will need to choose the "Unicode Text (*.txt)" file format.
    Andrew

  3. #33
    Member preston2's Avatar
    Real Name
    Preston
    Join Date
    Nov 2011
    Posts
    764

    Default Re: Importing Fractions in a String?

    Quote Originally Posted by Keith Hubert View Post
    Hi Guys,

    The sooner us Brits drop these fractions the better.
    When did "Brits" start using SAE? I thought you guys where all metric. Or does 1/8 mean 1/8th MM which does not sound right using 8th's on a system built around 10.

  4. #34
    "Certified" Alphaholic Keith Hubert's Avatar
    Real Name
    Keith Hubert
    Join Date
    Jul 2000
    Location
    London, UK
    Posts
    6,930

    Default Re: Importing Fractions in a String?

    Hi Andrew,

    Please see attached txt file.

    Your suggestion please how to import this into Alpha dbf.

    TIA.
    Attached Files Attached Files
    Regards
    Keith Hubert
    Alpha Guild Member
    London.
    KHDB Management Systems
    Skype = keith.hubert


    For your day-to-day Needs, you Need an Alpha Database!

  5. #35
    "Certified" Alphaholic
    Real Name
    Andrew Schone
    Join Date
    Dec 2005
    Location
    Kansas
    Posts
    1,047

    Default Re: Importing Fractions in a String?

    I will take a look at it but it may take a couple of days before I can get time freed up. Can you upload the excel file that was used to generate this output?
    Andrew

  6. #36
    "Certified" Alphaholic Stan Mathews's Avatar
    Real Name
    Stan Mathews
    Join Date
    Apr 2000
    Location
    Bowling Green, KY
    Posts
    25,119

    Default Re: Importing Fractions in a String?

    He was having trouble uploading an Excel file. Should be able to open Excel and open the text file within Excel.
    There can be only one.

  7. #37
    "Certified" Alphaholic
    Real Name
    Andrew Schone
    Join Date
    Dec 2005
    Location
    Kansas
    Posts
    1,047

    Default Re: Importing Fractions in a String?

    Quote Originally Posted by Stan Mathews View Post
    He was having trouble uploading an Excel file. Should be able to open Excel and open the text file within Excel.
    That worked
    Andrew

  8. #38
    "Certified" Alphaholic G Gabriel's Avatar
    Real Name
    G. Gabriel
    Join Date
    Oct 2004
    Posts
    7,204

    Default Re: Importing Fractions in a String?

    Keith:
    I think I got to the bottom of this.
    In alpha, characters are displayed as Windows ANSI Code in desktop applications, and as UTF8 in alpha web applications.
    So, perhaps, if you could display the imported data in a web project based on the table that has the imported data, you might be able to see and print these fractions.
    Give that a try first before exploring other solutions.
    There is a function that converts ANSI to UTF8, but if the characters are displayed as ANSI in the desktop app, I am not sure what good that will do. In the end, You will need to put this in a web app.
    For what's worth, the function is:
    convert_acp_to_utf8()

  9. #39
    "Certified" Alphaholic Keith Hubert's Avatar
    Real Name
    Keith Hubert
    Join Date
    Jul 2000
    Location
    London, UK
    Posts
    6,930

    Default Re: Importing Fractions in a String?

    Hi Gabe,

    Thanks for your suggestion. As per usual the picture is greater than the original question.

    This particular spreadsheet is one of many supplied by a number of Vendors to my client.

    All the data is being collected into one single table which is used as the Lookup for the Invoice. This is not a case of displaying the data on a form, but it would be used in the print out in any documents.
    Regards
    Keith Hubert
    Alpha Guild Member
    London.
    KHDB Management Systems
    Skype = keith.hubert


    For your day-to-day Needs, you Need an Alpha Database!

  10. #40
    "Certified" Alphaholic G Gabriel's Avatar
    Real Name
    G. Gabriel
    Join Date
    Oct 2004
    Posts
    7,204

    Default Re: Importing Fractions in a String?

    Quote Originally Posted by Keith Hubert View Post
    This is not a case of displaying the data on a form, but it would be used in the print out in any documents.
    I understand. If you build the web project (I think this is your best bet), you should be able to display the table's content in a grid and print it as well. The problem will arise if you wish to querry/filter the table. Is that something you will need to do?

  11. #41
    "Certified" Alphaholic Keith Hubert's Avatar
    Real Name
    Keith Hubert
    Join Date
    Jul 2000
    Location
    London, UK
    Posts
    6,930

    Default Re: Importing Fractions in a String?

    Hi Gabe,

    The data from this one table is to be appended to a much larger table that has all the products my client sells.

    This large table is used as a lookup and is filtered by the type of product my client is selling to their customer.

    I cant see the way forward with your valuable suggestion it this particular application. Unless I use SQL tables, what do you think?
    Regards
    Keith Hubert
    Alpha Guild Member
    London.
    KHDB Management Systems
    Skype = keith.hubert


    For your day-to-day Needs, you Need an Alpha Database!

  12. #42
    "Certified" Alphaholic
    Real Name
    Andrew Schone
    Join Date
    Dec 2005
    Location
    Kansas
    Posts
    1,047

    Default Re: Importing Fractions in a String?

    Keith -

    Here is what I got figured out. The script expects the file "Sample_Unicodet.txt" to be located in the same directory as the currently running .ADB. Also this script will create a output file called "Sample_ASCII.txt" as well as a new table called "Keith_Import.dbf". The table will then be added to the .ADB and a default browse opened.
    Attached Files Attached Files
    Andrew

  13. #43
    Volunteer Moderator
    Real Name
    Alan Buchholz
    Join Date
    Oct 2000
    Location
    Delavan, Wisconsin
    Posts
    9,625

    Default Re: Importing Fractions in a String?

    Andrew

    Nicely done.
    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.

  14. #44
    "Certified" Alphaholic G Gabriel's Avatar
    Real Name
    G. Gabriel
    Join Date
    Oct 2004
    Posts
    7,204

    Default Re: Importing Fractions in a String?

    Quote Originally Posted by Keith Hubert View Post
    Hi Gabe,
    The data from this one table is to be appended to a much larger table that has all the products my client sells.
    Size doesn't matter.
    Quote Originally Posted by Keith Hubert View Post
    This large table is used as a lookup and is filtered by the type of product my client is selling to their customer.
    Does the lookup filter include any of these fractions?
    Quote Originally Posted by Keith Hubert View Post
    Unless I use SQL tables, what do you think?
    Using a SQL might facilitate the import process and conversion to UTF8, but will it show on a alpha desktop app?
    I don't think so but I could be wrong.
    Let me see if I could clarify this better:
    Assume you have a regular standard TV set.
    Now you want to see your favorite channels in High Definition, so:
    You are happy to learn that your provider has these channels in HD
    You subscribe to HD
    You add a modem that is HD compatible.
    Will you see your channels in HD after doing all that?
    No.
    Because your TV is not HD.
    So, you could do everything under the sun and if you try to see these fractions in alpha in a desktop app, not happening. Because as I said earlier, alpha will show these fractions in ANSI not in UTF8, so they will show as "?", no matter what you do.
    The answer is, you need to show these in a Browser. A browser will recognize and show these UTF8 codes.
    But then again, I didn't test any of these and I could be wrong. Go with MySQL and the conversion and see what happens.

  15. #45
    "Certified" Alphaholic G Gabriel's Avatar
    Real Name
    G. Gabriel
    Join Date
    Oct 2004
    Posts
    7,204

    Default Re: Importing Fractions in a String?

    Perhaps I misunderstood your last question. Are you asking would it be better to use MySQL in lieu of alpha?

  16. #46
    "Certified" Alphaholic
    Real Name
    Andrew Schone
    Join Date
    Dec 2005
    Location
    Kansas
    Posts
    1,047

    Default Re: Importing Fractions in a String?

    Quote Originally Posted by Al Buchholz View Post
    Andrew

    Nicely done.
    Thank you
    Andrew

  17. #47
    "Certified" Alphaholic Keith Hubert's Avatar
    Real Name
    Keith Hubert
    Join Date
    Jul 2000
    Location
    London, UK
    Posts
    6,930

    Default Re: Importing Fractions in a String?

    Andrew,

    That is fantastic, many thanks. So fast too. 0.14 seconds.

    Fraction_Import.PNG

    One very small issue if you could just point me to the line that I should fix. There are double "" after each fraction and " at the beginning and end of each size.

    Your help is much appreciated.
    Regards
    Keith Hubert
    Alpha Guild Member
    London.
    KHDB Management Systems
    Skype = keith.hubert


    For your day-to-day Needs, you Need an Alpha Database!

  18. #48
    "Certified" Alphaholic
    Real Name
    Andrew Schone
    Join Date
    Dec 2005
    Location
    Kansas
    Posts
    1,047

    Default Re: Importing Fractions in a String?

    Good news: I got the extra " cleaned up
    Bad news: performance took a massive hit (probably a better way to do this)

    Replace the While ... End While loop with this one.

    Code:
    WHILE .not. vFileP.eof()
    	vTextC = vFileP.read_line()
    
    	'Cleanup extra " ( double quotes - chr(34) )
    	'There is an extra at the beginning of the string, after each fraction, and one at the end of the string
    	
    	'LTrim() - remove any specified leading characters in the Input_String.  Search_For_String can be used to specify a list of characters to trim from the start of the Input_String.
    	DIM vInput_StringC as C					'The character string to trim.
    	DIM vSearch_For_StringC as C			'Optional. Default = " " (space). The characters to trim from the left side of Input_String.
    	vInput_StringC = word(vTextC,3,chr(9))
    	vSearch_For_StringC = chr(34)
    	vInput_StringC = ltrim(vInput_StringC, vSearch_For_StringC)
    
    	'RTRIM() - removes any specified trailing characters in the Input_String. Default value for Search_For_String is space. However, Search_For_String can be used to specify a list of characters to trim from the end of the Input_String.
    	vInput_StringC = rtrim(vInput_StringC, vSearch_For_StringC)
    	
    	'Beginning and ending " (double quote - chr(34)) removed
    	'Now remove instances of "" (two double quotes in row); replace with one double quote (chr34)
    	DIM vFind_StringC as C					'The string to find in the Input_String.
    	DIM vReplace_StringC as C				'Optional. Default = "" (NULL). The string that replaces the Find_String
    	vFind_StringC = chr(34) + chr(34)
    	vReplace_StringC = chr(34)
    	vInput_StringC = strtran(vInput_StringC, vFind_StringC, vReplace_StringC)	
    	
    	DIM vSizeC as C							'vSizeC holds the final value that will be stored in the size column
    	vSizeC = vInput_StringC					'assign working value vInput_StringC to vSizeC
    	
    	vTblP.enter_begin()
    		vTblP.prod_code = word(vTextC,1,chr(9))
    		vTblP.desc = word(vTextC,2,chr(9))
    		vTblP.size = vSizeC
    		vTblP.unit = word(vTextC,4,chr(9))
    		'Word 5 does not exist - the excel to unicode created two tabs between UNIT and R.R.P £
    		vTblP.rrp = word(vTextC,6,chr(9))
    	vTblP.enter_end()
    END WHILE
    Andrew

  19. #49
    Volunteer Moderator
    Real Name
    Alan Buchholz
    Join Date
    Oct 2000
    Location
    Delavan, Wisconsin
    Posts
    9,625

    Default Re: Importing Fractions in a String?

    Or this way.

    Keith_Custom_Import2 - 03-25-2015 -1.txt

    It does have a couple of blank lines, but we need to leave something for Keith....
    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.

  20. #50
    "Certified" Alphaholic
    Real Name
    Andrew Schone
    Join Date
    Dec 2005
    Location
    Kansas
    Posts
    1,047

    Default Re: Importing Fractions in a String?

    Al -

    I like that method. Much faster than what I had.
    Andrew

  21. #51
    "Certified" Alphaholic Keith Hubert's Avatar
    Real Name
    Keith Hubert
    Join Date
    Jul 2000
    Location
    London, UK
    Posts
    6,930

    Default Re: Importing Fractions in a String?

    Hi Guys,

    You are both amazing. Speed issue 0.125 seconds. I think I can live with that, not even 1 second.

    Not to be picky, Al, you got rid of all the " but with a speed of 0.016. So for now it has to be the slower speed. But I will have a play with the code to see if I can get the " in the right places.

    Thanks again, you make this forum awesome!!!
    Regards
    Keith Hubert
    Alpha Guild Member
    London.
    KHDB Management Systems
    Skype = keith.hubert


    For your day-to-day Needs, you Need an Alpha Database!

  22. #52
    Volunteer Moderator
    Real Name
    Alan Buchholz
    Join Date
    Oct 2000
    Location
    Delavan, Wisconsin
    Posts
    9,625

    Default Re: Importing Fractions in a String?

    Quote Originally Posted by Keith Hubert View Post
    Hi Guys,

    You are both amazing. Speed issue 0.125 seconds. I think I can live with that, not even 1 second.

    Not to be picky, Al, you got rid of all the " but with a speed of 0.016. So for now it has to be the slower speed. But I will have a play with the code to see if I can get the " in the right places.

    Thanks again, you make this forum awesome!!!
    Adapt the list that Andrew wrote to include the "" at the end of the list.

    So the it's found and then replaced with the "

    Something like this?

    Keith_Custom_Import2 - 03-25-2015 -2.txt
    Last edited by Al Buchholz; 03-25-2015 at 04:34 PM.
    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.

  23. #53
    Volunteer Moderator
    Real Name
    Alan Buchholz
    Join Date
    Oct 2000
    Location
    Delavan, Wisconsin
    Posts
    9,625

    Default Re: Importing Fractions in a String?

    Thinking about it more, using an import operation instead of reading line by line got rid of most of the unwanted quotes.

    I add to change "" to " in the string substitution function.

    Keep tweaking until you get it right.
    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.

Similar Threads

  1. Programming Puzzle 3 - Fractions, anyone?
    By Tom Cone Jr in forum Xbasic Programming Puzzles
    Replies: 7
    Last Post: 11-08-2011, 06:40 AM
  2. help for numeric to fractions
    By nehru in forum Alpha Five Version 7
    Replies: 16
    Last Post: 09-07-2007, 02:34 PM
  3. Fractions
    By mcarroll in forum Alpha Five Version 6
    Replies: 6
    Last Post: 12-16-2004, 09:35 PM
  4. Data Input of fractions
    By kgilroy in forum Alpha Five Version 5
    Replies: 11
    Last Post: 11-20-2002, 12:19 AM
  5. Fractions - Special characters
    By kgilroy in forum Alpha Five Version 5
    Replies: 0
    Last Post: 11-19-2002, 01:29 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •