Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements

Breathe easy -- you now have more time to plan your next steps with Qlik!
QlikView 11.2 Extended Support is now valid through December 31, 2020. Click here for more information.

Not applicable

Double quotes enclosing some records when exporting to a TXT file

I'm trying to create a text file for import into another system.

There is only one field being exported, one field per row, but some rows are enclosed in double quotes.  I need a clean export without this.

Here is an example, that repeats for each HDR record:

Rec_String

|REC|1|100002-SM-AS|

"|HDR|SM-AS|100002|IC-DRAM-MOD, DDR2, 1GB, 667MHZ, SODIMM|Component|Active|VMI|BUY|gw@sm.com|"

|DET|NA|0|99.5|0|1000|1000|12||0||0|Active|Inactive||

I'm assuming those double quotes are thrown in because of the commas in the text of that field.  This data is constructed in other queries to be exported here, and it is delimited by the "|" character, so I do not need the system to include the double quotes.

How do I get rid of this?

Also, how do I get rid of the field name at the top, "Rec_String"?

Here is the store command I'm using:

Store FD_AS into 'C:\Documents\FD_FD-SM-S02-' (txt); // + year(now()) + Month(now()) + Day(now()) + '1201353535' + '.txt'

The stuff beyond the // is where I was trying to add a timestamp to the file name, but that is blowing up.  So, that would be a third question, how to concatenate those values onto the text.  I'm assuming using the Concat() function.  Not sure how to convert numeric to text right now, or if I have to.

So, three questions:

1) How to get rid of quotes?

2) How to get rid of field name?

3) How to concatenate the timestamp?

The questions are in order of importance.

Thank you.


Tags (2)
5 Replies
MVP
MVP

Re: Double quotes enclosing some records when exporting to a TXT file

Hi

1. To get the text delimited with the pipe character you need to change the (txt) output qualifier to (txt, delim is '|'). Then fields containing commas will not be quoted, but fields containing | will be quoted.

2. I don't know any way in QV to prevent the fieldname. You could call a Windows CMD file using a vbscript (or GnuTools) command to strip the leading row.

3. Its blowing up because you are trying to concatenate the string with the wrong operator. Use & instead of +. I would also simplify this be using Timestamp() to format the date field:

     '....FD_FD-SM-S02-' & Timestamp(Today(), 'YYYYMMDD hh:mm:ss') & '.txt'

HTH

Jonathan

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
MVP
MVP

Re: Double quotes enclosing some records when exporting to a TXT file

1)

replace(youronlyfield, chr(34), '')

Not applicable

Re: Double quotes enclosing some records when exporting to a TXT file

Well, the "|" character is already in the field.  I'm pulling a fully constructed, | delimited record string from an SQL Server view, and just using QV to export to a file.

I'm seeing the the documentation (which took several clicks to get to) that there are file designators like "fix", and "no quote" which I'm testing now.

That pointer on the & connector is helpful.

Thanks for the response.

Not applicable

Re: Double quotes enclosing some records when exporting to a TXT file

I don't believe I can use replace, because the quotes are not in the original field value, but is being created during the store to file.

Not applicable

Re: Double quotes enclosing some records when exporting to a TXT file

Doesn't look like it likes FIX or NO QUOTES in that usage.