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: 
haymarketpaul
Creator III
Creator 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)
8 Replies
pradosh_thakur
Master II
Master II

may be use 

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

in your data mode

Learning never stops.
haymarketpaul
Creator III
Creator III
Author

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

sunny_talwar


@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
Creator III
Creator III
Author

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

 

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

haymarketpaul
Creator III
Creator III
Author

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.

MattG
Contributor III
Contributor III

@haymarketpaul long shot, but did you ever make this work?

I'm in the exact same boat and can't figure it out.

haymarketpaul
Creator III
Creator III
Author

No sorry never cracked it from within Qlik - as it was only needed for a short while I ended up just using ASAP Utilities within Excel which has the adding double quotes function built into it.  You could also write some python code to do it (ask AI if unsure)

MattG
Contributor III
Contributor III

Thankyou for the reply, yep that's the route I'm looking to go down I reckon. A bit frustrating. 

Thanks!