download csv from web

User avatar
sal21
PlatinumLounger
Posts: 4362
Joined: 26 Apr 2010, 17:36

download csv from web

Post by sal21 »

Why instead the tipycal format of csv i have the result in attached file...

Code: Select all

Option Explicit
Dim NOMEFILE As String, URLFILE As String
Private Declare Function URLDownloadToFile Lib "urlmon" Alias "URLDownloadToFileA" (ByVal pCaller As Long, ByVal szURL As String, ByVal szFileName As String, ByVal dwReserved As Long, ByVal lpfnCB As Long) As Long
Public Function DownloadFile(URL As String, LocalFilename As String) As Boolean

    Dim lngRetVal As Long

    lngRetVal = URLDownloadToFile(0, URL, LocalFilename, 0, 0)
    If lngRetVal = 0 Then DownloadFile = True

End Function
Private Sub ESTRAI_DATA()

    NOMEFILE = "comuni_geocoded.csv"
    URLFILE = "https://github.com/gnekt/geolocalizzazione-comuni-italiani/blob/main/comuni_geocoded.csv"
    DownloadFile URLFILE, "C:\Lavori_Vb6\COMUNI_GEOCODE\FILE\" & NOMEFILE

End Sub
Private Sub Command1_Click()

    Call ESTRAI_DATA

End Sub 
You do not have the required permissions to view the files attached to this post.

User avatar
SpeakEasy
4StarLounger
Posts: 562
Joined: 27 Jun 2021, 10:46

Re: download csv from web

Post by SpeakEasy »

Because https://github.com/gnekt/geolocalizzazi ... ocoded.csv is not actually a CSV file ...

User avatar
sal21
PlatinumLounger
Posts: 4362
Joined: 26 Apr 2010, 17:36

Re: download csv from web

Post by sal21 »

SpeakEasy wrote:
24 Sep 2023, 11:57
Because https://github.com/gnekt/geolocalizzazi ... ocoded.csv is not actually a CSV file ...
:clapping: