check until value in txt change - i'm on vb6
-
- 5StarLounger
- Posts: 776
- Joined: 27 Jun 2021, 10:46
Re: check until value in txt change - i'm on vb6
Another alternative would be to treat the csv as a database.
-
- 5StarLounger
- Posts: 776
- Joined: 27 Jun 2021, 10:46
Re: check until value in txt change - i'm on vb6
e.g (you'll need an appropriate schema.ini as well, but that only needs to be created once, and an example is included below)
Exam,ple schema.ini
[test2.csv]
ColNameHeader=True
Format=Delimited(;)
Col1=F1 Char
Col2=F2 Char
Col3=F3 Char
Col4=F4 Char
Col5=F5 Char
Col6=F6 Char
Col7=F7 Char
Col8=F8 Integer
Col9=F9 Integer
Col10=F10 Integer
Code: Select all
Public Sub SAL21()
Dim myrow As Long
Dim resultset As Variant
With New Recordset
.Open "SELECT F2, Sum(F8) AS SumOfF8, Sum(F9) AS SumOfF9 , Sum(F10) AS SumOfF10 FROM test2.csv GROUP BY F2", "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\Downloads\DeleteMe;Extended Properties='text'", adOpenStatic
resultset = .GetRows
End With
For myrow = 0 To UBound(resultset, 2)
Debug.Print "ISTAT: " & resultset(0, myrow) & " MASCHI: " & resultset(1, myrow) & " FEMMINE: " & resultset(2, myrow) & " TOT: " & resultset(3, myrow)
Next
End Sub
[test2.csv]
ColNameHeader=True
Format=Delimited(;)
Col1=F1 Char
Col2=F2 Char
Col3=F3 Char
Col4=F4 Char
Col5=F5 Char
Col6=F6 Char
Col7=F7 Char
Col8=F8 Integer
Col9=F9 Integer
Col10=F10 Integer
-
- PlatinumLounger
- Posts: 4644
- Joined: 26 Apr 2010, 17:36
Re: check until value in txt change - i'm on vb6
TKs!SpeakEasy wrote: ↑23 Apr 2024, 13:46e.g (you'll need an appropriate schema.ini as well, but that only needs to be created once, and an example is included below)
Exam,ple schema.iniCode: Select all
Public Sub SAL21() Dim myrow As Long Dim resultset As Variant With New Recordset .Open "SELECT F2, Sum(F8) AS SumOfF8, Sum(F9) AS SumOfF9 , Sum(F10) AS SumOfF10 FROM test2.csv GROUP BY F2", "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\Downloads\DeleteMe;Extended Properties='text'", adOpenStatic resultset = .GetRows End With For myrow = 0 To UBound(resultset, 2) Debug.Print "ISTAT: " & resultset(0, myrow) & " MASCHI: " & resultset(1, myrow) & " FEMMINE: " & resultset(2, myrow) & " TOT: " & resultset(3, myrow) Next End Sub
[test2.csv]
ColNameHeader=True
Format=Delimited(;)
Col1=F1 Char
Col2=F2 Char
Col3=F3 Char
Col4=F4 Char
Col5=F5 Char
Col6=F6 Char
Col7=F7 Char
Col8=F8 Integer
Col9=F9 Integer
Col10=F10 Integer
i can use a where in your query?
-
- 5StarLounger
- Posts: 776
- Joined: 27 Jun 2021, 10:46
-
- PlatinumLounger
- Posts: 4644
- Joined: 26 Apr 2010, 17:36
Re: check until value in txt change - i'm on vb6
tks.
i have many files is this correct for multi file to use schema.ini:
[Dati_cittadinanza_2023.csv]
ColNameHeader=True
Format=Delimited(;)
Col1=F1 Char
Col2=F2 Char
Col3=F3 Char
Col4=F4 Char
Col5=F5 Char
Col6=F6 Char
Col7=F7 Char
Col8=F8 Integer
Col9=F9 Integer
Col10=F10 Integer
[Dati_cittadinanza_2022.csv]
ColNameHeader=True
Format=Delimited(;)
Col1=F1 Char
Col2=F2 Char
Col3=F3 Char
Col4=F4 Char
Col5=F5 Char
Col6=F6 Char
Col7=F7 Char
Col8=F8 Integer
Col9=F9 Integer
Col10=F10 Integer
[Dati_cittadinanza_2021.csv]
ColNameHeader=True
Format=Delimited(;)
Col1=F1 Char
Col2=F2 Char
Col3=F3 Char
Col4=F4 Char
Col5=F5 Char
Col6=F6 Char
Col7=F7 Char
Col8=F8 Integer
Col9=F9 Integer
Col10=F10 Integer
...
or
[Dati_cittadinanza_2023.csv]
[Dati_cittadinanza_2022.csv]
[Dati_cittadinanza_2021.csv]
ColNameHeader=True
Format=Delimited(;)
Col1=F1 Char
Col2=F2 Char
Col3=F3 Char
Col4=F4 Char
Col5=F5 Char
Col6=F6 Char
Col7=F7 Char
Col8=F8 Integer
Col9=F9 Integer
Col10=F10 Integer
-
- 5StarLounger
- Posts: 776
- Joined: 27 Jun 2021, 10:46
Re: check until value in txt change - i'm on vb6
The first one - separate entries for each file