Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

How to export a table to a text file without extra quotes

I have a table that has a single text field in it. When I export it to a csv file in a version 10 script, for example

store mytable into myfile.txt (txt)

QlikView wraps double quotes around the lines in myfile.txt if there are spaces in the line. Also, if there is a " in the text itself QlikView adds another " next to it.

I would like for the exported text file to not contain the added quotes. I can certainly post-process the text file but I would prefer not to. Does anyone have a solution for this?

Thanks,

Barry

24 Replies
rbecher
MVP
MVP

Hi babushka,

unfortunately it's not working. Which version you have?

- Ralf

Astrato.io Head of R&D
qlikviewforum
Creator II
Creator II

Hi All

I am also facing similar problem. In the attached spread sheet I have file location with double quotes. When I store it as a text file it adds two more double quotes along with that. I want to store the location in text file only with single double quotes. May I know how that can be achieved?

I know if I dont pass the double quotes along with the location txt file automatically adds single double quotes. But for some reasons I want to pass the double quotes along with the location. I am working on filesystems where I should consider the spaces between the folders(Eg: New Folder).

Any idea how that can be acheived please?

Output:

FilesLocation

XYZs"""C:\Test\New Folder"""

Oops also i think in the above output s got added along with the XYZ by iteself. That also need to be avoided! But first thing is achieving below output.

Expected output:

FilesLocation

XYZs"C:\Test\New Folder"

Hope some can help me out. Have attached the file for your reference!

Not applicable
Author

Hi Nicolai!

REALLY USEFUL POST!!

Thanks alot for sharing.

Not applicable
Author

HI,

      This is one of the Issue which everybody is facing .

What i found as per my understanding it is not a QlikView Bug .

http://community.qlik.com/thread/79439

//Yusuf

stevedark
Partner Ambassador/MVP
Partner Ambassador/MVP

Did anyone find an answer to this one?  In the past I have got around the problem by doing the store with a FileSystemObject write in a macro - but I've another case come up when I would much rather use a store on load.

Any suggestions welcome!

Steve

lalitinmbd
Partner - Contributor III
Partner - Contributor III

I am using this Macro to remove the extra Quotation marks in my txt file. It is removing the quotes but it is adding 1 into the txt file which is wrong. Any ideas why it is happening.

stevedark
Partner Ambassador/MVP
Partner Ambassador/MVP

Hi Lalit,

Can you post up the Macro code you are using?  Is the 1 on the first line?  If so, it is probably the column heading or a total.  If it's the latter you may be able to suppress it by turning off totals for the expressions.

I seem to recall that in the macro I used previously I loaded the whole text file into a variable in the macro and then did a replace on it to fix some of the odd things that QlikView was doing.

I really should have kept a copy of that code!

Steve

lalitinmbd
Partner - Contributor III
Partner - Contributor III

Hi Steve,

I am using the below Macro Code

Sub Export

          set obj = ActiveDocument.GetSheetObject("TB01")

          set pth = ActiveDocument.Variables("path")

          obj.Export pth.getcontent.string&"Export.txt", 1

          

' Replace the double quotes from the txt file. Could not find a way to export without??

         

          Const ForReading = 1

          Const ForWriting = 2

          Set objFSO = CreateObject("Scripting.FileSystemObject")

          Set objFile = objFSO.OpenTextFile(pth.getcontent.string&"Export.txt", ForReading)

          strText = objFile.ReadAll

          objFile.Close

          strOldText = Chr(34)&chr(34)

          strNewText = chr(0)

          strNewText = Replace(strText, strOldText, strNewText )

          Set objFile = objFSO.OpenTextFile(pth.getcontent.string&"Export.txt", ForWriting)

          objFile.WriteLine strNewText

          objFile.Close

         

End Sub

stevedark
Partner Ambassador/MVP
Partner Ambassador/MVP

If you can work out what the 1 is, and make it something else (eg. if it was a column label rename that column).  You could then do a further replace:

strNewText = Replace(Replace(strText, strOldText, strNewText ), 'Column Header', '')


Steve

lalitinmbd
Partner - Contributor III
Partner - Contributor III

Dear Steve,

I am surprised from where the 1 is coming as there is nowhere 1 in the column headers. When i do export using the macro. Below is my result.

Company1BO1Shop1Sales

Samsung1 "DAVIDOFF GOLD LIGHTS SLIM FI BOX 200 "1"TO00000031"130.50

"Samsung'"1BENSON & HEDGES GOLD FF KS FI BOX 2001TO00000006127.50

"Samsung "1BENSON & HEDGES GOLD FF KS FI BOX 4001TO00000002149.50

Sony1CAFE CREME 5X201TO00000224124.00

"Sams'ung"1CAMEL BLUE LIGHTS KS FI BOX 6001"TO00000017"175.00

Samsung*1CAMEL FF KS FI BOX 2001"TO00000013"129.50

  "Samsung  "1CAMEL FF KS FI BOX 4001"TO00000014"153.00

"Samsung ' Samsung"1DAVIDOFF CLASSIC FF KS FI BOX 2001TO00000030130.50

Samsung1DUNHILL BUTTON RED FF KS FI BOX 2001TO00000039130.00

Samsung1DUNHILL INTERNATIONAL BUTTON RED FF KS FI BOX 2001TO000000451"31.00"

Samsung1FORTUNA RED FF KS FI BOX 2001TO00000052127.50

Samsung1GAULOISES BLONDES BLUE FF KS FI BOX 2001TO00000059127.50

Samsung1GLAMOUR MENTHOL SS FI BOX 2001"TO00000071"1-

Samsung1KENT HD SILVER LIGHTS KS FI BOX 2001TO00000076130.00

MicroMax1L&M RED FF KS FI BOX 2001TO00000079127.50

MicroMax1LAMBERT & BUTLER FF KS FI BOX 4001TO00000082149.50

MicroMax1LUCKY STRIKE RED FF KS FI BOX 2001TO00000089127.50

MicroMax1LUCKY STRIKE RED FF KS FI BOX 4001TO00000090149.50

MicroMax1MARLBORO GOLD LIGHTS KS FI BOX 2001"TO00000104"130.00

Sony1MARLBORO GOLD LIGHTS KS FI BOX 4001"TO00000105"153.50

MicroMax1MARLBORO RED FF KS FI BOX 2001TO00000099130.00

Originally My Data is like

CompanyBOShopSales
"Samsung"BENSON & HEDGES GOLD FF KS FI BOX 400TO0000000249.50
Samsung'BENSON & HEDGES GOLD FF KS FI BOX 200TO0000000627.50
Samsung*CAMEL FF KS FI BOX 200TO0000001329.50
""Samsung""CAMEL FF KS FI BOX 400TO0000001453.00
Sams'ungCAMEL BLUE LIGHTS KS FI BOX 600TO0000001775.00
Samsung ' SamsungDAVIDOFF CLASSIC FF KS FI BOX 200TO0000003030.50
Samsung"DAVIDOFF GOLD LIGHTS SLIM FI BOX 200"TO0000003130.50
SamsungDUNHILL BUTTON RED FF KS FI BOX 200TO0000003930.00
SamsungDUNHILL INTERNATIONAL BUTTON RED FF KS FI BOX 200TO0000004531.00
SamsungFORTUNA RED FF KS FI BOX 200TO0000005227.50
SamsungGAULOISES BLONDES BLUE FF KS FI BOX 200TO0000005927.50
SamsungGLAMOUR MENTHOL SS FI BOX 200TO00000071
SamsungKENT HD SILVER LIGHTS KS FI BOX 200TO0000007630.00
MicroMaxL&M RED FF KS FI BOX 200TO0000007927.50
MicroMaxLAMBERT & BUTLER FF KS FI BOX 400TO0000008249.50

Regards

Lalit