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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

peraphs o.t. database street address 1

Status
Not open for further replies.

sal21

Programmer
Apr 26, 2004
422
IT
I need a csv file with street address of Italy...
Exist this possibility?
 
Er, this isn't really a VB6 question.

One would also suspect that you, as a Neopolitan, should know the answer to this better than many of we non-Italians in this forum

Still, if money is no object ... (you'll find this exact same file for the exact same price available under various different guises)

Free? You can download from here (although I am not sure how current they keep themselves), if you register: You'll need to drill down. I'd suggest that you are looking for the [tt]it/countrywide[/tt] dataset

Or you can learn how to query OpenMaps XML or PBF files ...

I'll just repeat - none of this is anything to do with VB6
 
TKS strong for big help!

Naturally i get he second option:) is free.

Attached is a part of file downloaded from site. (is big 3.56 Gb)

No idea to store the related value into a related var...

my idea is to read line by line...

related from the first line in file.

NR = the value 1 in "number":"1"
VIA = the value Via Giovanni Zirretta in "street":"Via Giovanni Zirretta"
...
CITTA ....
DISTRETTO ....
REGIONE ....
CAP (Is the postcode) ....
ID ....
LAT "coordinates":[13.583336,37.270182]}}
LNG "coordinates":[13.583336,37.270182]}}

Have an idea, tks.

note:
i have renamed the original file with .txt instead .geojson



 
 https://files.engineering.com/getfile.aspx?folder=ff8b6350-5808-4168-a0ad-291f3a3b53df&file=TEST1.zip
TKS strong for big help!

Naturally i get he second optionsmile is free.

Attached is a part of file downloaded from site. (is big 3.56 Gb)

No idea to store the related value into a related var...

my idea is to read line by line...

related from the first line in file.

NR = the value 1 in "number":"1"
VIA = the value Via Giovanni Zirretta in "street":"Via Giovanni Zirretta"
...
CITTA ....
DISTRETTO ....
REGIONE ....
CAP (Is the postcode) ....
ID ....
LAT "coordinates":[13.583336,37.270182]}}
LNG "coordinates":[13.583336,37.270182]}}

Have an idea, tks.

note:
i have renamed the original file with .txt instead .geojson
 
 https://files.engineering.com/getfile.aspx?folder=d243c26d-c7c9-4acf-9b41-f5f991ae6744&file=TEST1.txt
If you read your file line-by-line, you can Split() your line by "," (a comma) and you will have 12 elements array:

[pre]
0 {"type" :"Feature"
1 "properties" :{"hash":"3c735c941d6beb77"
2 "number" :"1"
3 "street" :"Via Giovanni Zirretta"
4 "unit" :""
5 "city" :"AGRIGENTO"
6 "district" :"AGRIGENTO"
7 "region" :"SICILIA"
8 "postcode" :"92100"
9 "id" :"13800023486246"}
10 "geometry" :{"type":"Point"
11 "coordinates":[13.583336
12 37.270182]}}
[/pre]
Then if you Split() element 2 by ":", you get 2 elements array: (0)"number" and (1)"1"
You can do the same with other elements of your array to get what you need (hopefully)

---- Andy

"Hmm...they have the internet on computers now"--Homer Simpson
 
TKS, strong but not completly understand, tk for code in other case.
 
My progress... is correct?

Code:
Sub READ_JSON()
    
    Dim arrFileLines() As Variant, I As Long, objFSO As Object, objFile As Object, L As Long
    
    Dim NR As String
    Dim VIA As String
    Dim CITTA As String
    Dim DISTRETTO As String
    Dim REGIONE As String
    Dim CAP As String
    Dim ID As String
    Dim COORD As String
    Dim PARTS() As String
    Dim LNG As String
    Dim LAT As String, LINEA As String, RIGA As String
    
    I = 0
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    Set objFile = objFSO.OpenTextFile("C:\Lavori_Vb6\STRADARIO\FILE\it_countrywide-addresses-country.TXT", 1)
    
    Do Until objFile.AtEndOfStream
    
        ReDim Preserve arrFileLines(I)
        arrFileLines(I) = objFile.ReadLine
        
        I = I + 1
        
        If I Mod 50000 = 0 Then
' FOR TESTING
            Exit Do
        End If
        
    Loop
    
    objFile.Close
    
    For L = LBound(arrFileLines) To UBound(arrFileLines)
        'Debug.Print arrFileLines(L)
        LINEA = Split(arrFileLines(L), ",")(0)
        LINEA = Split(arrFileLines(L), ",")(1)
        LINEA = Split(arrFileLines(L), ",")(2)
        LINEA = Split(arrFileLines(L), ",")(3)
        LINEA = Split(arrFileLines(L), ",")(4)
        LINEA = Split(arrFileLines(L), ",")(5)
        LINEA = Split(arrFileLines(L), ",")(6)
        LINEA = Split(arrFileLines(L), ",")(7)
        LINEA = Split(arrFileLines(L), ",")(8)
        LINEA = Split(arrFileLines(L), ",")(9)
        LINEA = Split(arrFileLines(L), ",")(10)
        LINEA = Split(arrFileLines(L), ",")(11)
        LINEA = Split(arrFileLines(L), ",")(12)
    Next
    
    Set objFSO = Nothing
    Set objFile = Nothing
    
End Sub
 
Your code could be a lot shorter:

Code:
Sub READ_JSON()
Dim strTextLine As String
Dim ary() As String

Open "C:\Lavori_Vb6\STRADARIO\FILE\it_countrywide-addresses-country.TXT" For Input As #1
Do While Not EOF(1)
    Line Input #1, strTextLine
    ary = Split(strTextLine, ",")
    
    MsgBox Split(ary(2), ":")(0) & " - " & Split(ary(2), ":")(1)
    MsgBox Split(ary(3), ":")(0) & " - " & Split(ary(3), ":")(1)
    MsgBox Split(ary(5), ":")(0) & " - " & Split(ary(5), ":")(1)[green]
    'Exit Do[/green]
Loop
Close #1

End Sub

Or you can parse json string in vb6

---- Andy

"Hmm...they have the internet on computers now"--Homer Simpson
 
>Or you can parse json string in vb6

sal21 has already been given and appeared to accept a JSON solution in another forum he frequents 3 days ago. Which is why I am a bit surprised he has left this thread open.

And for simple JSON, we don't need any additional 3rd party class libraries. Just need to leverage the sctipting runtime, eg thread329-1789285
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top