Qlik Community

New to QlikView

Discussion board where members can get started with QlikView.

haymarketpaul
Contributor III

Storing into CSV with Comma and Double Quotes

QV Nov 2017 SR4

 

Having trawled through numerous posts (although some quite old) I'm not sure if this is even possible but I need to save a table to a CSV file with all fields enclosed in double quotes.  It is for uploading into another system that is very specific on the format.

So this sort of thing:-

"ID","CompanyName","JobTitle"

"12345","Haymarket","Data Analyst"

 

I can happily save to a csv using this variable and STORE command:-

LET vCSVExport = '\\' & '$(vHammstore)' & '\Direct\Circulation\Data ops\Directories\SDL Export\Directories_$(vTodaysDate).csv (txt)';

STORE temp into $(vCSVExport);

I'm not sure how if possible to apply the double quotes?

 

I've tried putting msq before and after the txt part ie ...(msq,txt)';    or   ...(txt,msq)';

but get this...

Unexpected token: 'msq', expected one of: 'qvd', 'txt', 'qvx', 'delimiter'

STORE temp into \\HAMMSTORE\Direct\Circulation\Data ops\Directories\SDL Export\Directories_19-02-2019.csv (>>>>>>msq<<<<<<,txt)

and this respectively...............

Unexpected token: 'msq', expected one of: ')', 'qvd', 'txt', 'qvx', 'delimiter'

STORE temp into \\HAMMSTORE\Direct\Circulation\Data ops\Directories\SDL Export\Directories_19-02-2019.csv (txt,>>>>>>msq<<<<<<)

 

Not sure what else to try so any ideas much appreciated

Labels (1)
5 Replies
pradosh_thakur
Honored Contributor II

Re: Storing into CSV with Comma and Double Quotes

may be use 

chr(34) & your_field & chr(34) as  your_field  

in your data mode

Learning never stops.
haymarketpaul
Contributor III

Re: Storing into CSV with Comma and Double Quotes

Thanks for the idea - unfortunately testing it on a couple of fields ends up with this sort of thing (for some reason?) in the CSV file.

 

"""145323""","""Angus Heathers""",

 

Also it doesn't affect the header row

Re: Storing into CSV with Comma and Double Quotes


@haymarketpaul wrote:

Also it doesn't affect the header row


For this may be you would want to load your first row as data itself and then you will have an extra row, but your header row will have double quotes around it

LET vDoubleQuote = Chr(34);

Table:
LOAD '$(vDoubleQuote)' & F1 & '$(vDoubleQuote)' as [F1],
	 '$(vDoubleQuote)' & F2 & '$(vDoubleQuote)' as [F2],
	 '$(vDoubleQuote)' & F3 & '$(vDoubleQuote)' as [F3];
LOAD * INLINE [
	F1, F2, F3
    ID, CompanyName, JobTitle
    12345, Haymarket, Data Analyst
];

STORE Table into Table.csv (txt);

This will create a csv like this

image.png

haymarketpaul
Contributor III

Re: Storing into CSV with Comma and Double Quotes

Thanks Sunny - still gives me this though with extra "s for some reason

 

F1,F2,F3
"""ID""","""CompanyName""","""JobTitle"""
"""12345""","""Haymarket""","""Data Analyst"""

haymarketpaul
Contributor III

Re: Storing into CSV with Comma and Double Quotes

Strangely it appears this is/was possible according to this post from Sept last year....

https://community.qlik.com/t5/QlikView-Deployment/Storing-into-CSV-with-Comma-and-Double-Quotes/m-p/...

...but even Miguel's (Qlik Employee) attached example gives me the same multiple quote problem?

 

Alas I'll have to explore some other way of achieving it I guess.