Re: [U2] CSV to Array
Oh that is interesting ... will have to give that a run! Thanks Wol! -Original Message- From: u2-users-boun...@listserver.u2ug.org [mailto:u2-users-boun...@listserver.u2ug.org] On Behalf Of Wols Lists Sent: Thursday, August 16, 2012 7:40 AM To: u2-users@listserver.u2ug.org Subject: Re: [U2] CSV to Array On 15/08/12 23:24, David Wolverton wrote: > I've done this in the past by doing this: > > SWAP DQUOTE WITH @AM > > Now, in theory, every EVEN attribute is a 'quoted' string - don't > touch the commas > Every ODD attribute is a 'non-quoted' string... > > Double check me here in case I've lost it... but this should work ... > seems this would be faster as well on larger records. Only thing > you'd have to test for -- if the first character is a doublequote, we > will have a blank first attribute and should not -- but that could be > tested in the END ELSE section (IF XXX = 1 THEN IF DATASTRING[1,1] = 1 > THEN CONTINUE) > Given that you're parsing on a delimiter, actually the best tool here is probably MATPARSE! You need two dimensions, however. Something like DIM ARRAY(100,2) MATPARSE STRING USING ',"' Until I actually played with it, I didn't realise it put text into column 1, and delimiters into column 2. Which makes it easy to ding through. If say you have a comma followed by two double quotes, it will put the comma in column 2, a blank in column 1, and then both double quotes in the next element in column 2. I was actually parsing a maths statement, but it was so easy ... Cheers, Wol ___ U2-Users mailing list U2-Users@listserver.u2ug.org http://listserver.u2ug.org/mailman/listinfo/u2-users ___ U2-Users mailing list U2-Users@listserver.u2ug.org http://listserver.u2ug.org/mailman/listinfo/u2-users
Re: [U2] CSV to Array
And I missed the whole 'Escaping Double Quotes' thread -- so this is already covered... Skip this post!! ;-) -Original Message- From: u2-users-boun...@listserver.u2ug.org [mailto:u2-users-boun...@listserver.u2ug.org] On Behalf Of David Wolverton Sent: Thursday, August 16, 2012 5:42 PM To: 'U2 Users List' Subject: Re: [U2] CSV to Array You can't have "3/4" Bolts" in the data stream -- that would not work. So that means the embedded " has to be 'escaped' - usually by a \.. So you'd have "3/4\" Bolts" or the like ... right? In that case, you'd want to 'swap' out the \" for some other 'hold character' first -- like &&DQOUTE&& And Then swap out the 'remaining' '"' out as listed. I did forget that! At the very end, you 're-swap' &&DQUOTE&& for '"' DW -Original Message- From: u2-users-boun...@listserver.u2ug.org [mailto:u2-users-boun...@listserver.u2ug.org] On Behalf Of Mecki Foerthmann Sent: Thursday, August 16, 2012 2:26 AM To: u2-users@listserver.u2ug.org Subject: Re: [U2] CSV to Array The moment you start working in the engineering or manufacturing industry where it is not uncommon to have double quotes embedded in a field (i.e 5 1/4" Steel Bar) your code will bite you. On 15/08/2012 23:24, David Wolverton wrote: > I've done this in the past by doing this: > > SWAP DQUOTE WITH @AM > > Now, in theory, every EVEN attribute is a 'quoted' string - don't > touch the commas > Every ODD attribute is a 'non-quoted' string... > > Double check me here in case I've lost it... but this should work ... > seems this would be faster as well on larger records. Only thing > you'd have to test for -- if the first character is a doublequote, we > will have a blank first attribute and should not -- but that could be > tested in the END ELSE section (IF XXX = 1 THEN IF DATASTRING[1,1] = 1 > THEN CONTINUE) > > DATASTRING = 'A,B,"C,D",E,F,"G,H,I",J,K,L NEWSTRING = "" > SWAP '"' WITH @AM IN DATASTRING > AMCNT = DCOUNT(DATASTRING,@AM) > FOR XXX = 1 TO AMCNT >IF MOD(AMCNT,2) = 0 THEN > NEWSTRING := @AM: DATASTRING >END ELSE > DATAROW = NEWSTRING > SWAP ',' WITH @AM IN DATAROW > NEWSTRING := @AM:DATAROW > NEWSTRING<-1> = DATAROW >END > NEXT XXX > > > -Original Message- > From: u2-users-boun...@listserver.u2ug.org > [mailto:u2-users-boun...@listserver.u2ug.org] On Behalf Of Wjhonson > Sent: Wednesday, August 15, 2012 4:11 PM > To: u2-users@listserver.u2ug.org > Subject: [U2] CSV to Array > > > Rex Gozar uploaded this code, and someone (perhaps him) corrected it, > but there's a redundancy here. I'm trying to fix it, in my own > version, mostly > perhaps I *hate* the CONTINUE, but the logic is a bit convoluted eh? Anyone > spot the redundancy ? > >EQU COMMA TO ',' >EQU DQ TO '"' >BUFFER = TEXT >BUFPTR = 0 >CPTR = 0 >QUOTESW = @FALSE >LOOP > CPTR += 1 > C = BUFFER[CPTR,1] >WHILE (C NE "") DO > IF (DQ EQ C) THEN > IF (QUOTESW) AND (DQ:DQ EQ BUFFER[CPTR,2]) THEN > CPTR += 1 > END ELSE > QUOTESW = NOT(QUOTESW) > CONTINUE > END > END > IF (COMMA EQ C) AND NOT(QUOTESW) THEN > C = @FM > END > BUFPTR += 1 > BUFFER[BUFPTR,1] = C >REPEAT >RECORD = BUFFER[1,BUFPTR] >RETURN > END > > ___ > U2-Users mailing list > U2-Users@listserver.u2ug.org > http://listserver.u2ug.org/mailman/listinfo/u2-users > > ___ > U2-Users mailing list > U2-Users@listserver.u2ug.org > http://listserver.u2ug.org/mailman/listinfo/u2-users > ___ U2-Users mailing list U2-Users@listserver.u2ug.org http://listserver.u2ug.org/mailman/listinfo/u2-users ___ U2-Users mailing list U2-Users@listserver.u2ug.org http://listserver.u2ug.org/mailman/listinfo/u2-users ___ U2-Users mailing list U2-Users@listserver.u2ug.org http://listserver.u2ug.org/mailman/listinfo/u2-users
Re: [U2] CSV to Array
You can't have "3/4" Bolts" in the data stream -- that would not work. So that means the embedded " has to be 'escaped' - usually by a \.. So you'd have "3/4\" Bolts" or the like ... right? In that case, you'd want to 'swap' out the \" for some other 'hold character' first -- like &&DQOUTE&& And Then swap out the 'remaining' '"' out as listed. I did forget that! At the very end, you 're-swap' &&DQUOTE&& for '"' DW -Original Message- From: u2-users-boun...@listserver.u2ug.org [mailto:u2-users-boun...@listserver.u2ug.org] On Behalf Of Mecki Foerthmann Sent: Thursday, August 16, 2012 2:26 AM To: u2-users@listserver.u2ug.org Subject: Re: [U2] CSV to Array The moment you start working in the engineering or manufacturing industry where it is not uncommon to have double quotes embedded in a field (i.e 5 1/4" Steel Bar) your code will bite you. On 15/08/2012 23:24, David Wolverton wrote: > I've done this in the past by doing this: > > SWAP DQUOTE WITH @AM > > Now, in theory, every EVEN attribute is a 'quoted' string - don't > touch the commas > Every ODD attribute is a 'non-quoted' string... > > Double check me here in case I've lost it... but this should work ... > seems this would be faster as well on larger records. Only thing > you'd have to test for -- if the first character is a doublequote, we > will have a blank first attribute and should not -- but that could be > tested in the END ELSE section (IF XXX = 1 THEN IF DATASTRING[1,1] = 1 > THEN CONTINUE) > > DATASTRING = 'A,B,"C,D",E,F,"G,H,I",J,K,L NEWSTRING = "" > SWAP '"' WITH @AM IN DATASTRING > AMCNT = DCOUNT(DATASTRING,@AM) > FOR XXX = 1 TO AMCNT >IF MOD(AMCNT,2) = 0 THEN > NEWSTRING := @AM: DATASTRING >END ELSE > DATAROW = NEWSTRING > SWAP ',' WITH @AM IN DATAROW > NEWSTRING := @AM:DATAROW > NEWSTRING<-1> = DATAROW >END > NEXT XXX > > > -Original Message- > From: u2-users-boun...@listserver.u2ug.org > [mailto:u2-users-boun...@listserver.u2ug.org] On Behalf Of Wjhonson > Sent: Wednesday, August 15, 2012 4:11 PM > To: u2-users@listserver.u2ug.org > Subject: [U2] CSV to Array > > > Rex Gozar uploaded this code, and someone (perhaps him) corrected it, but > there's a redundancy here. I'm trying to fix it, in my own version, mostly > perhaps I *hate* the CONTINUE, but the logic is a bit convoluted eh? Anyone > spot the redundancy ? > >EQU COMMA TO ',' >EQU DQ TO '"' >BUFFER = TEXT >BUFPTR = 0 >CPTR = 0 >QUOTESW = @FALSE >LOOP > CPTR += 1 > C = BUFFER[CPTR,1] >WHILE (C NE "") DO > IF (DQ EQ C) THEN > IF (QUOTESW) AND (DQ:DQ EQ BUFFER[CPTR,2]) THEN > CPTR += 1 > END ELSE > QUOTESW = NOT(QUOTESW) > CONTINUE > END > END > IF (COMMA EQ C) AND NOT(QUOTESW) THEN > C = @FM > END > BUFPTR += 1 > BUFFER[BUFPTR,1] = C >REPEAT >RECORD = BUFFER[1,BUFPTR] >RETURN > END > > ___ > U2-Users mailing list > U2-Users@listserver.u2ug.org > http://listserver.u2ug.org/mailman/listinfo/u2-users > > ___ > U2-Users mailing list > U2-Users@listserver.u2ug.org > http://listserver.u2ug.org/mailman/listinfo/u2-users > ___ U2-Users mailing list U2-Users@listserver.u2ug.org http://listserver.u2ug.org/mailman/listinfo/u2-users ___ U2-Users mailing list U2-Users@listserver.u2ug.org http://listserver.u2ug.org/mailman/listinfo/u2-users
Re: [U2] [JOB] Opportunity for non-MV techie to learn MV in Atlanta, GA
WJhonson wrote: > > You didn't add *because* Bruce :) > Why would they want someone with no Pick experience? > As I reply, please bear in mind that postings do not carry verbal inflection! This is a friendly reply. Those who know me know of my sense of humor. Having stated that, humor may not, in fact, be present as humor is subjective. No offense is intended nor implied by this reply. Wil, Indeed I did. As you are so fond of doing to others in some of your replies, I reply in kind: Please read my Original Post. Quoting, "I am not the one with the details but can put you in touch with the one who does. I can say that no MV experience is required. The database is UniVerse with OHM software. The company will train." You're a very smart man. If it were not explicit I believe you could have inferred. The two salient points: 1) I am not the one with the details but can put you in touch with the one who does. That means I'm taking no questions! I will put you in touch with the one who can get the answers. 2) The company will train. I would assume they do not want to retrain old dogs and/or they wish to contain costs. I hope this helps! *grinning* Bruce -- View this message in context: http://old.nabble.com/-OT--Opportunity-for-non-MV-techie-to-learn-MV-in-Atlanta%2C-GA-tp34294905p34309094.html Sent from the U2 - Users mailing list archive at Nabble.com. ___ U2-Users mailing list U2-Users@listserver.u2ug.org http://listserver.u2ug.org/mailman/listinfo/u2-users
Re: [U2] [JOB] Opportunity for non-MV techie to learn MV in Atlanta, GA
Or the position doesn't require it so there wouldn't be any point in paying for it. -Original Message- From: u2-users-boun...@listserver.u2ug.org [mailto:u2-users-boun...@listserver.u2ug.org] On Behalf Of John Lorentz Sent: Thursday, August 16, 2012 1:30 PM To: U2 Users List Subject: Re: [U2] [JOB] Opportunity for non-MV techie to learn MV in Atlanta,GA On Thu, Aug 16, 2012 at 11:26 AM, Wjhonson wrote: > You didn't add *because* Bruce :) > Why would they want someone with no Pick experience? Because they're cheaper? (They obviously don't value that experience.) John ___ U2-Users mailing list U2-Users@listserver.u2ug.org http://listserver.u2ug.org/mailman/listinfo/u2-users ___ U2-Users mailing list U2-Users@listserver.u2ug.org http://listserver.u2ug.org/mailman/listinfo/u2-users
Re: [U2] [JOB] Opportunity for non-MV techie to learn MV in Atlanta, GA
On Thu, Aug 16, 2012 at 11:26 AM, Wjhonson wrote: > You didn't add *because* Bruce :) > Why would they want someone with no Pick experience? Because they're cheaper? (They obviously don't value that experience.) John ___ U2-Users mailing list U2-Users@listserver.u2ug.org http://listserver.u2ug.org/mailman/listinfo/u2-users
Re: [U2] [JOB] Opportunity for non-MV techie to learn MV in Atlanta, GA
You didn't add *because* Bruce :) Why would they want someone with no Pick experience? -Original Message- From: BruceHolt To: u2-users Sent: Thu, Aug 16, 2012 10:56 am Subject: Re: [U2] [JOB] Opportunity for non-MV techie to learn MV in Atlanta, GA Tony Gravagno-3 wrote: > > And as discussed many times, the way to create a new generation is > clear and employed by every new product on the market. We can do it if > only there were real desire. But this industry simply refuses to learn > or follow the examples of the mainstream. More importantly, everyone > including the DBMS vendors leaves Marketing to everyone else because > they don't have a stomach for the expense/investment. > > To question a song on the matter: Is suicide really painless? > > T > (yeah yeah, OT...) > > I purposely delayed my response to Wil to see what else showed up! It was worth it. Anyway, to directly answer Wil, the recruiter friend of mine told me the company does not want to hire an experienced UniVerse developer. They want to hire someone freshly out of college that they can train. Fresh blood. In our industry yet! Novel idea, I know! Bruce -- View this message in context: http://old.nabble.com/-OT--Opportunity-for-non-MV-techie-to-learn-MV-in-Atlanta%2C-GA-tp34294905p34308157.html Sent from the U2 - Users mailing list archive at Nabble.com. ___ U2-Users mailing list U2-Users@listserver.u2ug.org http://listserver.u2ug.org/mailman/listinfo/u2-users ___ U2-Users mailing list U2-Users@listserver.u2ug.org http://listserver.u2ug.org/mailman/listinfo/u2-users
Re: [U2] [JOB] Opportunity for non-MV techie to learn MV in Atlanta, GA
Tony Gravagno-3 wrote: > > And as discussed many times, the way to create a new generation is > clear and employed by every new product on the market. We can do it if > only there were real desire. But this industry simply refuses to learn > or follow the examples of the mainstream. More importantly, everyone > including the DBMS vendors leaves Marketing to everyone else because > they don't have a stomach for the expense/investment. > > To question a song on the matter: Is suicide really painless? > > T > (yeah yeah, OT...) > > I purposely delayed my response to Wil to see what else showed up! It was worth it. Anyway, to directly answer Wil, the recruiter friend of mine told me the company does not want to hire an experienced UniVerse developer. They want to hire someone freshly out of college that they can train. Fresh blood. In our industry yet! Novel idea, I know! Bruce -- View this message in context: http://old.nabble.com/-OT--Opportunity-for-non-MV-techie-to-learn-MV-in-Atlanta%2C-GA-tp34294905p34308157.html Sent from the U2 - Users mailing list archive at Nabble.com. ___ U2-Users mailing list U2-Users@listserver.u2ug.org http://listserver.u2ug.org/mailman/listinfo/u2-users
Re: [U2] CSV to Array
It is tempting to use SWAP or CONVERT statements when parsing CSV, but they never handle all the possible cases correctly. You have to look at each character and keep track of state. rex ___ U2-Users mailing list U2-Users@listserver.u2ug.org http://listserver.u2ug.org/mailman/listinfo/u2-users
Re: [U2] Web Error
Delete LIVE.DATA from your ODBC connections and recreate it -Original Message- From: u2-users-boun...@listserver.u2ug.org [mailto:u2-users-boun...@listserver.u2ug.org] On Behalf Of Israel, John R. Sent: 16 August 2012 18:09 To: 'U2 Users List' Subject: [U2] Web Error Yesterday, we had a DR test where we used all of our DR hardware to test our DR plan. Everything in Avante went fine as did most of our ePortal testing. However, when it came to the web pages connecting to the Avante account (as opposed to connecting to the ePortal account), I am getting the nebulous 500 error message in my browser. To eliminate any misleading messages, I have bounced RedBack (thus clearing out the logs and starting fresh), stopped IIS, cleared all logs in IIS, changed Windows\rgw.ini to use the DR box name (wdhp7640), then restarted IIS. When I attempt to go to the web page in question, I get: 2012-08-16 16:38:28 172.16.1.22 POST /ePortal/std/storefront/shipping.asp guid=43442041196|162|80004005|Can't_connect_to_account_'LIVE.DATA'_(wdhp 7640:8509)_rc=-1_ 443 - 192.168.9.232 Mozilla/4.0+(compatible;+MSIE+7.0;+Windows+NT+6.1;+WOW64;+Trident/5.0;+S LCC2;+.NET+CLR+2.0.50727;+.NET+CLR+3.5.30729;+.NET+CLR+3.0.30729;+InfoPa th.2;+.NET4.0C;+.NET4.0E) 500 0 0 15537 The key point being: "Can't_connect_to_account_'LIVE.DATA'_(wdhp7640:8509)" Here is the updated Windows\rgw.ini rbexamples wdhp7640:8501 rbodemo wdhp7640:8502 EPORTAL wdhp7640:8503 LIVE.DATA wdhp7640:8509 <== EPORTAL_PILOT wdhp7640:8505 PILOT.DATA wdhp7640:8506 EPORTAL_DEV wdhp7640:8507 TEST.DATA wdhp7640:8508 [LogLevel] panic=1 err=1 wrn=0 inf=0 init=0 trace=0 verb=0 big=0 What am I missing? It connects to the EPORTAL account just fine. I have convinced management to leave things in a DR mode until the end of the day to try to figure this out. John ___ U2-Users mailing list U2-Users@listserver.u2ug.org http://listserver.u2ug.org/mailman/listinfo/u2-users Click https://www.mailcontrol.com/sr/wQw0zmjPoHdJTZGyOCrrhg== s+!ICtCF3ulfLlPD6aicL5PvYXhYd9V7qILtzovJ!KJwA== to report this email as spam. Epicor Software (UK) is a limited company registered in England & Wales. Registration Number: 2338274. Registered Office: 6th Floor, One London Wall, London EC2Y 5EB This e-mail is for the use of the intended recipient(s) only. If you have received this e-mail in error, please notify the sender immediately and then delete it. If you are not the intended recipient, you must not use, disclose or distribute this e-mail without the author's prior permission. We have taken precautions to minimize the risk of transmitting software viruses, but we advise you to carry out your own virus checks on any attachment to this message. We cannot accept liability for any loss or damage caused by software viruses. Any views and/or opinions expressed in this e-mail are of the author only and do not represent the views of Epicor Software (UK) Limited or any other company within its group. This message has been scanned for malware by Websense. www.websense.com ___ U2-Users mailing list U2-Users@listserver.u2ug.org http://listserver.u2ug.org/mailman/listinfo/u2-users
[U2] Web Error
Yesterday, we had a DR test where we used all of our DR hardware to test our DR plan. Everything in Avanté went fine as did most of our ePortal testing. However, when it came to the web pages connecting to the Avanté account (as opposed to connecting to the ePortal account), I am getting the nebulous 500 error message in my browser. To eliminate any misleading messages, I have bounced Redback (thus clearing out the logs and starting fresh), stopped IIS, cleared all logs in IIS, changed Windows\rgw.ini to use the DR box name (wdhp7640), then restarted IIS. When I attempt to go to the web page in question, I get: 2012-08-16 16:38:28 172.16.1.22 POST /eportal/std/storefront/shipping.asp guid=43442041196|162|80004005|Can't_connect_to_account_'LIVE.DATA'_(wdhp7640:8509)_rc=-1_ 443 - 192.168.9.232 Mozilla/4.0+(compatible;+MSIE+7.0;+Windows+NT+6.1;+WOW64;+Trident/5.0;+SLCC2;+.NET+CLR+2.0.50727;+.NET+CLR+3.5.30729;+.NET+CLR+3.0.30729;+InfoPath.2;+.NET4.0C;+.NET4.0E) 500 0 0 15537 The key point being: "Can't_connect_to_account_'LIVE.DATA'_(wdhp7640:8509)" Here is the updated Windows\rgw.ini rbexamples wdhp7640:8501 rbodemo wdhp7640:8502 EPORTAL wdhp7640:8503 LIVE.DATA wdhp7640:8509 <== EPORTAL_PILOT wdhp7640:8505 PILOT.DATA wdhp7640:8506 EPORTAL_DEV wdhp7640:8507 TEST.DATA wdhp7640:8508 [LogLevel] panic=1 err=1 wrn=0 inf=0 init=0 trace=0 verb=0 big=0 What am I missing? It connects to the EPORTAL account just fine. I have convinced management to leave things in a DR mode until the end of the day to try to figure this out. John ___ U2-Users mailing list U2-Users@listserver.u2ug.org http://listserver.u2ug.org/mailman/listinfo/u2-users
Re: [U2] CSV to Array
Thanks for the support. As I was working my way through the code I posted I noticed that if you embedded in the quote is a check to see if the character we're on *and* the next character are both double quotes. But if that's true, than the initial check for a double quote to even get *into* that section is redundant. You can't have two double quotes in a row if you don't start with a double quote to begin. Of course the opposite case is true, you could start with a double quote and no have two double quotes in a row. Perhaps tomorrow I will post the code with which I ended up. Written as a subroutine, then maybe someone can break it. Will ___ U2-Users mailing list U2-Users@listserver.u2ug.org http://listserver.u2ug.org/mailman/listinfo/u2-users
Re: [U2] CSV to Array
Tab seems to be the default character of choice of mysql/mssql output as well. As well, Excel seems to like "" to mean ", but other programs seem to want \" So tab works good here as well. But I still use comma when exporting to clients, unless they ask for tabs. -Original Message- From: u2-users-boun...@listserver.u2ug.org [mailto:u2-users-boun...@listserver.u2ug.org] On Behalf Of Charlie Noah Sent: Thursday, August 16, 2012 5:26 AM To: U2 Users List Subject: Re: [U2] CSV to Array I have double quotes in my product descriptions, and yes, they are a pain! I also prepare Google Shopping data feeds for clients who don't want to fight it themselves. This is why I prefer tab delimited with no surround character. Unless you have tabs in your actual data, no problems. Technically, it's not csv anymore, but who cares? Charlie Noah Tiny Bear's Wild Bird Store "Everything For The Backyard Bird Enthusiast, Except For The Birds" http://www.TinyBearWildBirdStore.com Toll Free: 1-855-TinyBear (855-846-9232) ___ U2-Users mailing list U2-Users@listserver.u2ug.org http://listserver.u2ug.org/mailman/listinfo/u2-users
Re: [U2] CSV to Array
-Original Message- From: u2-users-boun...@listserver.u2ug.org [mailto:u2-users-boun...@listserver.u2ug.org] On Behalf Of Dianne Ackerman Sent: Thursday, August 16, 2012 7:52 AM To: U2 Users List Subject: Re: [U2] CSV to Array I actually enjoy reading wjhonson's "puzzle" posts with code examples, etc. Maybe they can be flagged in the header so those of you who don't want to read them can just skip them. -Dianne On 8/15/2012 5:49 PM, Tony Gravagno wrote: > Anyone getting paid to play guessing games? Dude, get to the point. If > this were presented as "I need help" I think many people would jump to > help. But presenting this as a Mensa challenge is just wasting > people's time. > T > > Wjhonson wrote: > > Rex Gozar uploaded this code, and someone (perhaps him) corrected > it, >> but there's a redundancy here. I'm trying to fix it, in my own > version, >> mostly perhaps I *hate* the CONTINUE, but the logic is a bit > convoluted >> eh? Anyone spot the redundancy ? > ___ ___ U2-Users mailing list U2-Users@listserver.u2ug.org http://listserver.u2ug.org/mailman/listinfo/u2-users ___ U2-Users mailing list U2-Users@listserver.u2ug.org http://listserver.u2ug.org/mailman/listinfo/u2-users
Re: [U2] CSV to Array
Sincerely, David Laansma IT Manager Hubbard Supply Co. Direct: 810-342-7143 Office: 810-234-8681 Fax: 810-234-6142 www.hubbardsupply.com "Delivering Products, Services and Innovative Solutions" -Original Message- From: u2-users-boun...@listserver.u2ug.org [mailto:u2-users-boun...@listserver.u2ug.org] On Behalf Of Dianne Ackerman Sent: Thursday, August 16, 2012 8:52 AM To: U2 Users List Subject: Re: [U2] CSV to Array I actually enjoy reading wjhonson's "puzzle" posts with code examples, etc. Maybe they can be flagged in the header so those of you who don't want to read them can just skip them. -Dianne On 8/15/2012 5:49 PM, Tony Gravagno wrote: > Anyone getting paid to play guessing games? Dude, get to the point. If > this were presented as "I need help" I think many people would jump to > help. But presenting this as a Mensa challenge is just wasting > people's time. > T > > Wjhonson wrote: > > Rex Gozar uploaded this code, and someone (perhaps him) corrected > it, >> but there's a redundancy here. I'm trying to fix it, in my own > version, >> mostly perhaps I *hate* the CONTINUE, but the logic is a bit > convoluted >> eh? Anyone spot the redundancy ? > ___ ___ U2-Users mailing list U2-Users@listserver.u2ug.org http://listserver.u2ug.org/mailman/listinfo/u2-users ___ U2-Users mailing list U2-Users@listserver.u2ug.org http://listserver.u2ug.org/mailman/listinfo/u2-users
Re: [U2] CSV to Array
I actually enjoy reading wjhonson's "puzzle" posts with code examples, etc. Maybe they can be flagged in the header so those of you who don't want to read them can just skip them. -Dianne On 8/15/2012 5:49 PM, Tony Gravagno wrote: Anyone getting paid to play guessing games? Dude, get to the point. If this were presented as "I need help" I think many people would jump to help. But presenting this as a Mensa challenge is just wasting people's time. T Wjhonson wrote: > Rex Gozar uploaded this code, and someone (perhaps him) corrected it, but there's a redundancy here. I'm trying to fix it, in my own version, mostly perhaps I *hate* the CONTINUE, but the logic is a bit convoluted eh? Anyone spot the redundancy ? ___ ___ U2-Users mailing list U2-Users@listserver.u2ug.org http://listserver.u2ug.org/mailman/listinfo/u2-users
Re: [U2] CSV to Array
On 15/08/12 23:24, David Wolverton wrote: > I've done this in the past by doing this: > > SWAP DQUOTE WITH @AM > > Now, in theory, every EVEN attribute is a 'quoted' string - don't touch the > commas > Every ODD attribute is a 'non-quoted' string... > > Double check me here in case I've lost it... but this should work ... seems > this would be faster as well on larger records. Only thing you'd have to > test for -- if the first character is a doublequote, we will have a blank > first attribute and should not -- but that could be tested in the END ELSE > section (IF XXX = 1 THEN IF DATASTRING[1,1] = 1 THEN CONTINUE) > Given that you're parsing on a delimiter, actually the best tool here is probably MATPARSE! You need two dimensions, however. Something like DIM ARRAY(100,2) MATPARSE STRING USING ',"' Until I actually played with it, I didn't realise it put text into column 1, and delimiters into column 2. Which makes it easy to ding through. If say you have a comma followed by two double quotes, it will put the comma in column 2, a blank in column 1, and then both double quotes in the next element in column 2. I was actually parsing a maths statement, but it was so easy ... Cheers, Wol ___ U2-Users mailing list U2-Users@listserver.u2ug.org http://listserver.u2ug.org/mailman/listinfo/u2-users
Re: [U2] CSV to Array
I have double quotes in my product descriptions, and yes, they are a pain! I also prepare Google Shopping data feeds for clients who don't want to fight it themselves. This is why I prefer tab delimited with no surround character. Unless you have tabs in your actual data, no problems. Technically, it's not csv anymore, but who cares? Charlie Noah Tiny Bear's Wild Bird Store "Everything For The Backyard Bird Enthusiast, Except For The Birds" http://www.TinyBearWildBirdStore.com Toll Free: 1-855-TinyBear (855-846-9232) On 08-16-2012 2:25 AM, Mecki Foerthmann wrote: The moment you start working in the engineering or manufacturing industry where it is not uncommon to have double quotes embedded in a field (i.e 5 1/4" Steel Bar) your code will bite you. On 15/08/2012 23:24, David Wolverton wrote: I've done this in the past by doing this: SWAP DQUOTE WITH @AM Now, in theory, every EVEN attribute is a 'quoted' string - don't touch the commas Every ODD attribute is a 'non-quoted' string... Double check me here in case I've lost it... but this should work ... seems this would be faster as well on larger records. Only thing you'd have to test for -- if the first character is a doublequote, we will have a blank first attribute and should not -- but that could be tested in the END ELSE section (IF XXX = 1 THEN IF DATASTRING[1,1] = 1 THEN CONTINUE) DATASTRING = 'A,B,"C,D",E,F,"G,H,I",J,K,L NEWSTRING = "" SWAP '"' WITH @AM IN DATASTRING AMCNT = DCOUNT(DATASTRING,@AM) FOR XXX = 1 TO AMCNT IF MOD(AMCNT,2) = 0 THEN NEWSTRING := @AM: DATASTRING END ELSE DATAROW = NEWSTRING SWAP ',' WITH @AM IN DATAROW NEWSTRING := @AM:DATAROW NEWSTRING<-1> = DATAROW END NEXT XXX -Original Message- From: u2-users-boun...@listserver.u2ug.org [mailto:u2-users-boun...@listserver.u2ug.org] On Behalf Of Wjhonson Sent: Wednesday, August 15, 2012 4:11 PM To: u2-users@listserver.u2ug.org Subject: [U2] CSV to Array Rex Gozar uploaded this code, and someone (perhaps him) corrected it, but there's a redundancy here. I'm trying to fix it, in my own version, mostly perhaps I *hate* the CONTINUE, but the logic is a bit convoluted eh? Anyone spot the redundancy ? EQU COMMA TO ',' EQU DQ TO '"' BUFFER = TEXT BUFPTR = 0 CPTR = 0 QUOTESW = @FALSE LOOP CPTR += 1 C = BUFFER[CPTR,1] WHILE (C NE "") DO IF (DQ EQ C) THEN IF (QUOTESW) AND (DQ:DQ EQ BUFFER[CPTR,2]) THEN CPTR += 1 END ELSE QUOTESW = NOT(QUOTESW) CONTINUE END END IF (COMMA EQ C) AND NOT(QUOTESW) THEN C = @FM END BUFPTR += 1 BUFFER[BUFPTR,1] = C REPEAT RECORD = BUFFER[1,BUFPTR] RETURN END ___ U2-Users mailing list U2-Users@listserver.u2ug.org http://listserver.u2ug.org/mailman/listinfo/u2-users ___ U2-Users mailing list U2-Users@listserver.u2ug.org http://listserver.u2ug.org/mailman/listinfo/u2-users ___ U2-Users mailing list U2-Users@listserver.u2ug.org http://listserver.u2ug.org/mailman/listinfo/u2-users ___ U2-Users mailing list U2-Users@listserver.u2ug.org http://listserver.u2ug.org/mailman/listinfo/u2-users
Re: [U2] CSV to Array
The moment you start working in the engineering or manufacturing industry where it is not uncommon to have double quotes embedded in a field (i.e 5 1/4" Steel Bar) your code will bite you. On 15/08/2012 23:24, David Wolverton wrote: I've done this in the past by doing this: SWAP DQUOTE WITH @AM Now, in theory, every EVEN attribute is a 'quoted' string - don't touch the commas Every ODD attribute is a 'non-quoted' string... Double check me here in case I've lost it... but this should work ... seems this would be faster as well on larger records. Only thing you'd have to test for -- if the first character is a doublequote, we will have a blank first attribute and should not -- but that could be tested in the END ELSE section (IF XXX = 1 THEN IF DATASTRING[1,1] = 1 THEN CONTINUE) DATASTRING = 'A,B,"C,D",E,F,"G,H,I",J,K,L NEWSTRING = "" SWAP '"' WITH @AM IN DATASTRING AMCNT = DCOUNT(DATASTRING,@AM) FOR XXX = 1 TO AMCNT IF MOD(AMCNT,2) = 0 THEN NEWSTRING := @AM: DATASTRING END ELSE DATAROW = NEWSTRING SWAP ',' WITH @AM IN DATAROW NEWSTRING := @AM:DATAROW NEWSTRING<-1> = DATAROW END NEXT XXX -Original Message- From: u2-users-boun...@listserver.u2ug.org [mailto:u2-users-boun...@listserver.u2ug.org] On Behalf Of Wjhonson Sent: Wednesday, August 15, 2012 4:11 PM To: u2-users@listserver.u2ug.org Subject: [U2] CSV to Array Rex Gozar uploaded this code, and someone (perhaps him) corrected it, but there's a redundancy here. I'm trying to fix it, in my own version, mostly perhaps I *hate* the CONTINUE, but the logic is a bit convoluted eh? Anyone spot the redundancy ? EQU COMMA TO ',' EQU DQ TO '"' BUFFER = TEXT BUFPTR = 0 CPTR = 0 QUOTESW = @FALSE LOOP CPTR += 1 C = BUFFER[CPTR,1] WHILE (C NE "") DO IF (DQ EQ C) THEN IF (QUOTESW) AND (DQ:DQ EQ BUFFER[CPTR,2]) THEN CPTR += 1 END ELSE QUOTESW = NOT(QUOTESW) CONTINUE END END IF (COMMA EQ C) AND NOT(QUOTESW) THEN C = @FM END BUFPTR += 1 BUFFER[BUFPTR,1] = C REPEAT RECORD = BUFFER[1,BUFPTR] RETURN END ___ U2-Users mailing list U2-Users@listserver.u2ug.org http://listserver.u2ug.org/mailman/listinfo/u2-users ___ U2-Users mailing list U2-Users@listserver.u2ug.org http://listserver.u2ug.org/mailman/listinfo/u2-users ___ U2-Users mailing list U2-Users@listserver.u2ug.org http://listserver.u2ug.org/mailman/listinfo/u2-users