Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

import data from the web

Status
Not open for further replies.

thegame8311

Technical User
Jan 6, 2012
133
US
Greetings all

Is there a way to import data from the web straight to foxpro or is it easier to go through excel to foxpro
 
now for my issue with AT()

Have you looked in your VFP Help for information on how to use the AT() function?

If you had done so you would have seen that the sample code you listed above is wrong.

AT(<what to search for>,<where to look for it>,<which occurance to find>)

The same question applies - Have you looked in your VFP Help for information on how to use the SUBSTR() function?

SUBSTR(<which expression>, <where to START>, <how many characters>)

So, guessing from the SUBSTR() part of your code, you should be issuing a ALLTRIM(SUBSTR(z,AT(',',z)+1))

If you have questions about VFP Commands/Functions first look at your VFP Help for answers.
That does not, in any way, mean that we aren't happy to help, but that you can get most of these type of answers yourself with a little work on your own.

Good Luck,
JRB-Bldr
 
this is my list:
Doe, John
Smith, Joan

what is returned is:
Doe
Doe

Then you're always working on the same z="Doe, Joan". Show the loop and we can help you to get a different z for each line of the list.

Bye, Olaf.
 
Here is my for loop

Code:
FOR lnI = 1 to lnCount3
  laHyper3(lnI) = ALINES(laHyper3,z,",")
  lp1.text3.value = laHyper(lnI)
  newline3 = laHyper3(lnI)
  FWRITE (lnFileHandle3, newline3)
  FWRITE (lnFileHandle3, Chr(13))
  FWRITE (lnFileHandle3, Chr(10))
ENDFOR

and for some reason laHyper(1) returns 76

instead of Doe
 
This is where you are going wrong:

Code:
 laHyper3(lnI) = ALINES(laHyper3,z,",")

ALINES returns a count of the number of lines that it finds. The actual line gets stored in the array (laHyper() in your example).

I suggest you read the help on all these functions. In the case of ALINES(), you might also find this article useful:
Parsing comma-delimited strings into a Visual Foxpro array.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips, training, consultancy
 
Another possibility is to use GETWORDNUM() and GETWORDCOUNT().

Just want to point out that ALINES()' speed is linear with string length. These functions are definitely not, and as strings get long, they get really slow.

Tamar
 
To make Mikes answer a bit more to the point:
ALINES creates the whole array laHyper3, not just one array element.
So you would do one ALINE() call BEFORE the loop on the resulting array.

Code:
* lnFileHandle3 = FOpen(...)
* z sample value
z = "Huey,Dewey,Louie"
* split z at commas, create an array laHyper3
lnCountOfArrayElements = ALINES(laHyper3,z,",")
* loop through the split parts of z
FOR lnI = 1 to lnCountOfArrayElements 
  lp1.text3.value = laHyper(lnI)
  newline3 = laHyper3(lnI)
  FWRITE (lnFileHandle3, newline3+Chr(13)+Chr(10))
ENDFOR
* FClose(lnFileHandle3)

What you didn't show is the loop changing z. My loop as the correction of the loop you showed is just processing a single z, not a list of z values.

In thjis sampele this will result in two lines "Jane" and "Doe". I don't think that is what you want. You need a loop changing z, going through the list of names you have there.

Bye, Olaf.
 
so in the case above by olaf:

laHyper3(1)= Doe
laHyper3(2) = Jane

or am i misreading it?
 
so in the case above by olaf:
laHyper3(1)= Doe
laHyper3(2) = Jane

No. In Olaf's example, the original string contains "Huey,Dewey,Louie", so laHyper3(1) will contain "Huey"; laHyper3(2) will contain "Dewey".

You know, you can always play around with these functions in the Command Window. That's probably the best way to figure out how they work.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips, training, consultancy
 
Yes I have been playing with the functions in the command window.

Thank you everybody for your help, with all your ideas I have gotten the right combination of functions to do what I was wanting, you guys are awesome
 
Sorry, the text of my last posting was misleading, as I changed the code to split "Huey,Dewey,Louie" and still talked about it creating two lines "Jane" and "Doe".

But you go it, good.

Bye, Olaf.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top