I have a bat file where I encode some CSV files to UTF-8, and then import the files to a SQLite database. This is the code I have:
echo Codificando ficheros...
powershell -Command "&{ param($Path); (Get-Content $Path) | Out-File $Path -Encoding UTF8 }" CSVs\\prefijo.csv
powershell -Command "&{ param($Path); (Get-Content $Path) | Out-File $Path -Encoding UTF8 }" CSVs\\materiales.csv
powershell -Command "&{ param($Path); (Get-Content $Path) | Out-File $Path -Encoding UTF8 }" CSVs\\zonas.csv
powershell -Command "&{ param($Path); (Get-Content $Path) | Out-File $Path -Encoding UTF8 }" CSVs\\responsables.csv
powershell -Command "&{ param($Path); (Get-Content $Path) | Out-File $Path -Encoding UTF8 }" CSVs\\lideres.csv
powershell -Command "&{ param($Path); (Get-Content $Path) | Out-File $Path -Encoding UTF8 }" CSVs\\pass.csv
powershell -Command "&{ param($Path); (Get-Content $Path) | Out-File $Path -Encoding UTF8 }" CSVs\\capacidadLotes.csv
powershell -Command "&{ param($Path); (Get-Content $Path) | Out-File $Path -Encoding UTF8 }" CSVs\\boletosIndirectos.csv
@echo OFF
echo Generando fichero de base de datos _datosPrecargados.db...
.\sqlite3.exe BaseDatos\_datosPrecargados.db < Sentencias_sql\Sentencias_DatosPrecargados.sql
@echo OFF
echo Generando fichero de base de datos _inventario.db...
.\sqlite3.exe BaseDatos\_inventario.db < Sentencias_sql\Sentencias_Inventario.sql
pause
Before I set the PowerShell lines to encode the files it worked fine. But before encoding I have a problem. The data base seems to be ok but when I do a select sentence looking for the first column of the first record, it is not found.
E.G. Table "zones":
zone name
---- ----
Z001 Zone 1
Z002 Zone 2
Z002 Zone 3
If I execute the sentence "SELECT * FROM zones"
, it lists all the records, ok.
If I execute the sentence "SELECT * FROM zones WHERE zone="Z002""
, the record is listed, ok.
But if I execute the sentence "SELECT * FROM zones WHERE zone="Z001""
, the record is not found.
If I don't set the PowerShell line in the bat file, it doesn't happens and it works fine, but I need to encode the files because I have special characters inside the CSV files like "ñ" or "ó".
I don´t know what can I am doing wrong.
Thanks in advance!!