Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi,
I'm trying to store a table in ansi codification but when I open the file with notepad++ it appears in utf8 format,
this is the scriptline i'm using:
store "ga" into 'E:\QlikView\Development\filename.csv' (codepage is 1252,txt,delimiter is ';');
I've tried too :
store "ga" into 'E:\QlikView\Development\filename.csv' (ansi, txt, delimiter is ';');
Also I've selected 'ansi' in the menus "Document propperties-->general-->character to export"
and in "User preferences-->Export-->Codification"
Any aidea??
David
We use the following code in a module. You will need to define three variables in the qlikview document to provide the path and filenames.
Public Sub ConvertInterFaceFileUTF8toANSI()
Dim StrText
Dim adReadAll
Dim adSaveCreateOverWrite
Dim adTypeBinary
Dim adTypeText
Dim adWriteChar
Dim DestDir
Dim UTF8FName
Dim ANSIFName
DestDir = ActiveDocument.GetVariable("vInterfaceFileDirectory").getcontent.string
UTF8FName = ActiveDocument.GetVariable("vInterFaceUTF8FileName").getcontent.string
ANSIFName = ActiveDocument.GetVariable("vInterfaceFileName").getcontent.string
adReadAll = -1
adSaveCreateOverWrite = 2
adTypeBinary = 1
adTypeText = 2
adWriteChar = 0
With CreateObject("ADODB.Stream")
.Open
.Type = adTypeBinary
.LoadFromFile DestDir & UTF8FName
.Type = adTypeText
.Charset = "utf-8"
strText = .ReadText(adReadAll)
.Position = 0
.SetEOS
.Charset = "_autodetect" 'Use current ANSI codepage.
.WriteText strText, adWriteChar
.SaveToFile DestDir & ANSIFName, adSaveCreateOverWrite
.Close
End With
End sub
Hi,
Just try
store ga into E:\QlikView\Development\filename.csv(txt);
Regards,
Kaushik Solanki
I've tried but still store the file in utf8 format...
Hi,
According to the help file.
When you use store command to export the data into CSv it will always be in UTF8 Format.
"A QVD or a CSV file can be created by a store statement in the script. The statement will create an explicitly named QVD or CSV file. The statement can only export fields from one logical table. The text values are exported to the CSV file in UTF-8 format."
If you want you can create a macro to store the file in such way. And call that macro on every load operation.
Regards,
Kaushik Solanki
Thanks,
I didn't see it,
do you have an example of a macro to convert the file codification?
Regards,
David
Hi,
No Not at the moment but sure i will upload if i get the solution.
Regards,
Kaushik Solanki
Ok,
Thanks for all Kaushik!!
We use the following code in a module. You will need to define three variables in the qlikview document to provide the path and filenames.
Public Sub ConvertInterFaceFileUTF8toANSI()
Dim StrText
Dim adReadAll
Dim adSaveCreateOverWrite
Dim adTypeBinary
Dim adTypeText
Dim adWriteChar
Dim DestDir
Dim UTF8FName
Dim ANSIFName
DestDir = ActiveDocument.GetVariable("vInterfaceFileDirectory").getcontent.string
UTF8FName = ActiveDocument.GetVariable("vInterFaceUTF8FileName").getcontent.string
ANSIFName = ActiveDocument.GetVariable("vInterfaceFileName").getcontent.string
adReadAll = -1
adSaveCreateOverWrite = 2
adTypeBinary = 1
adTypeText = 2
adWriteChar = 0
With CreateObject("ADODB.Stream")
.Open
.Type = adTypeBinary
.LoadFromFile DestDir & UTF8FName
.Type = adTypeText
.Charset = "utf-8"
strText = .ReadText(adReadAll)
.Position = 0
.SetEOS
.Charset = "_autodetect" 'Use current ANSI codepage.
.WriteText strText, adWriteChar
.SaveToFile DestDir & ANSIFName, adSaveCreateOverWrite
.Close
End With
End sub
Thanks to all!
Thanks. You've helped me out of a sticky situation!