Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Nov. 20th, Qlik Insider - Lakehouses: Driving the Future of Data & AI - PICK A SESSION
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Ansi codification

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

1 Solution

Accepted Solutions
chriscammers
Partner - Specialist
Partner - Specialist

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

View solution in original post

11 Replies
kaushiknsolanki
Partner Ambassador/MVP
Partner Ambassador/MVP

Hi,

   Just try

   

   store  ga into E:\QlikView\Development\filename.csv(txt);

  

Regards,

Kaushik Solanki 

Please remember to hit the 'Like' button and for helpful answers and resolutions, click on the 'Accept As Solution' button. Cheers!
Not applicable
Author

I've tried but still store the file in utf8 format...

kaushiknsolanki
Partner Ambassador/MVP
Partner Ambassador/MVP

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

Please remember to hit the 'Like' button and for helpful answers and resolutions, click on the 'Accept As Solution' button. Cheers!
Not applicable
Author

Thanks,

I didn't see it,

do you have an example of a macro to convert the file codification?

Regards,

David

kaushiknsolanki
Partner Ambassador/MVP
Partner Ambassador/MVP

Hi,

   No Not at the moment but sure i will upload if i get the solution.

Regards,

Kaushik Solanki

Please remember to hit the 'Like' button and for helpful answers and resolutions, click on the 'Accept As Solution' button. Cheers!
Not applicable
Author

Ok,

Thanks for all Kaushik!!

chriscammers
Partner - Specialist
Partner - Specialist

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

Not applicable
Author

Thanks to all!

Not applicable
Author

Thanks. You've helped me out of a sticky situation!